How do I get my (if "input" in list) to check every letter of the input and not just the first letter of input?

gmanread

How do I get my (if "input" in list) to check every letter of the input and not just the first letter of input?

This is my code now:

alphabet = "abcdefghijklmnopqrstuvwxyzæø˚a ?"

my_list=list(alphabet)
n= input()



def textis():
for word in n.split():
    if word in my_list:
      print(word)
    else:
        x=word.replace(n,"?")
        print (x)



textis()

but it only checks the first letter of the input. I want it to check every letter of input and change the ones that dont are in list to "?", and print the input again with the changes "?" in the sentence. So if input is, hello My name Is, output should be hello ?y name ?s.

Prayush Dawda

Here are the problems:

  • You need to pass in arguments in a function.
  • You need to check every letter in the word instead of checking and changing the entire word.

What I did was make a new variable and made changes to that variable and then returned this variable.

alphabet = "abcdefghijklmnopqrstuvwxyzæø˚a ?"

my_list = list(alphabet)
n = input()

def textis(n, my_list):
  new = ''
  for letter in n:
    if letter in my_list:
      new += letter
    else:
      new += "?"
  return new

print(textis(n, my_list))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I compare user input to an uppercase letter string in a list?

How to uppercase every letter of my input sentences? (In Java)

How to get the script to only return one letter of the first name they Input?

Trying to create a guess my letter code. How do I incorporate the case where the input char from the user equals my letter?

How do i take the input quote from a user and shuffle it then put every letter separate in a table in JavaScript

How to avoid first letter to be capitalized on input field

how do I get charAt() to check every first letter after splitting a string?

how do you get the first letter of a name from user input and put it into a if loop?

Getting just the first letter of the user input in C++

How do I use the if statement for input starting with a certain letter

How do I only accept capital letter as user input?

Is there a way to check the first letter of every word and delete a word based on user input in python?

Disable zero as first letter in <input>

recognition first letter in input stream

Program ignores the first letter of input

Check if input is number or letter javascript

How to get an input as either a letter or an integer?

Javascript to auto-capitalize first letter of every word in input fields

How do I add multiple lines of txt into an array and compare each letter to a user-input letter?

Read input from a file, capitalize first letter, make every other letter lowercase, and output into a separate file

I want to make secureTextEntry my text input in react native true, But when write the first letter is false

Why do I lose the focus of the input when I write the first letter?

Convert input letter to different letter

How to capitalized only first letter of sentence in input fields with javascript?

How to redirect to a page according to the first letter written into an input field (PHP)

How to capitalize first letter of EACH WORD, in input type text

VUE.JS + Bootstrap - How to capitalize first letter in the same input

How to check if a text input string on change has an Uppercase letter Javascript

How to check if a text input string on change has a Lowercase letter Javascript