0

With this code what I am trying to do is not letting input names which don't contain vowels. It works when in the if there is only 1 vowel but when I try more than one it doesn't. I know the or in python means and/or. I have researched but I don't find an explanation why this happens. The code's sintaxis is ok. Can anyone tell me how the character's work?

var = False #Sets var to False

while var == False: #While var is False do this:

  name = str(input("What is your name? ")) #Input name and Print what is your name?

  if "a" or "e" or "i" or "o" or "u" in name: #If name contains a or e or i or o or u
    var = True #Set var to True

print ("Success") #Print Success
JaviHGM
  • 13
  • 6

1 Answers1

2
var = False     
while var == False:     
  name = str(input("What is your name? ")) 
  if any(i in 'aeiou' for i in name.lower()):   
    var = True  

print ("Success")
Smart Manoj
  • 5,230
  • 4
  • 34
  • 59