Conditional statement

Conditional statement

if <condition>:

True here

statements

elif <condition>:

True here

statements

…

else:

Catch all other here

statements

Example:

key=input("enter key\n")
value=int(input("enter value\n"))
d={key:value}
if d['a']==1:
    print('yes')
elif d['a']==2:
    print('no')
else:
    print('unknown')

enter key
a
enter value
1
yes

Last updated