Conditional statement

Conditional statement

if <condition>:

True here

statements
elif <condition>:

True here

statements
…
else:

Catch all other here

statements
Example:
1
key=input("enter key\n")
2
value=int(input("enter value\n"))
3
d={key:value}
4
if d['a']==1:
5
print('yes')
6
elif d['a']==2:
7
print('no')
8
else:
9
print('unknown')
10
​
11
enter key
12
a
13
enter value
14
1
15
yes
Copied!
Last modified 1yr ago