In python "else if" is spelled "elif".
Also, you need a colon after the elif and the else.
Simple answer to a simple question. I had the same problem, when I first started (in the last couple of weeks).
So your code should read:
def function(a):
if a == '1':
print('1a')
elif a == '2':
print('2a')
else:
print('3a')
function(input('input:'))
Answer from Frames Catherine White on Stack OverflowIn python "else if" is spelled "elif".
Also, you need a colon after the elif and the else.
Simple answer to a simple question. I had the same problem, when I first started (in the last couple of weeks).
So your code should read:
def function(a):
if a == '1':
print('1a')
elif a == '2':
print('2a')
else:
print('3a')
function(input('input:'))
Do you mean elif?
Help! If / Else statements.
Nose alternatives - nose2, pytest or something else?
dumb python question about if statements
Python 3.10 Match statements are 86% faster than If statements
Videos
I’m trying to learn python (literal first day) and I’ve ran into a rut.
Please any help and understanding would be fantastic.
1 num= 8941%931 2 3# Define if/else condition 4 if(_ _): 5 #Print message below 6 Print (“The number num is “, _ _ ) 7 else: 8 #print another message below 9 print (“the number num is “, _ _ )
I need help with the ( _ _ ). I’m not sure what to put there.
TIA