5 Antworten
+ 6
Python 'if' block is built with indentation, simply reduce the indentation level of the next instruction line to put it out of the block.
year = 2018
if year == 2018:
# code in 'if' block codes
# last line in 'if' block
print(year) # 'if' block ends above
+ 4
Python usa espacios para diferenciar lo que esta dentro deñ if de lo que esta afuera
if True:
#Esto esta adentro
#Esto esta adentro
#Esto esta afuera
+ 3
if a == b:
print("a is equal to b")
elif a > b:
print("a is larger than b")
else:
print("a is smaller than b")
+ 1
if x = 0:
#in if statement
#not in if statement
0
it runs and eventually stops when its done with indented content.
or
are you looking for
else:
# do something
pass