How do you tell your program to do nothing?


#1

So if I have an if statement and if that if statement is true, I want the program to do nothing.
How do i tell the program to do nothing if the statement is true. This occurs in the if statement. If I put an else statement right after, there will be an error.

Also I have another problem. Instead of typing the same statement in the if statement, is there another way to evaluate or statements like
if i == “i” or “u”…
instead of having to put
if i ==“i” or i == “u”…

def anti_vowel(text):
–word = ‘’
–for i in text:
----if i == “i” or i == “u” or i == “o” or i == “a” or i == “e” or i == “A” or i == “E” or i == “O” or i == “I” or i == “U” :
----else:
------word += i
–print word
–return word
anti_vowel(“hello”)
anti_vowel(“WHat is your Name@!@!”)


#2

to do nothing, you can use pass

ideally, you would avoid this. Then its better to use not equal (!=) instead of equal in your condition. But this also would also require to use and instead of or

can’t do, then python will simply evaluate "u" to true

you can make a string or list with all the vowels and then use the in keyword to check if i is in the vowel list/string


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.