+ 1
Hey, can anyone help.. My program is not running when I use break and continue statment, 1st one is running but 2nd and 3 not
1) words = ["hello","shello","fello","sello"] for x in words: print (x) 2) words = ["hello","shello","fello","sello"] for x in words: If x == "fello" break print (x) 3) cars = ["BMW", "Mercedes", "Audi", "Nissan", "Toyota"] for x in cars: if x == "Nissan" continue print (x)
2 Answers
+ 7
You forgot the : after the if statements
2)
words = ["hello","shello","fello","sello"]
for x in words:
if x == "fello":
break
print (x)
3)
cars = ["BMW", "Mercedes", "Audi", "Nissan", "Toyota"]
for x in cars:
if x == "Nissan":
continue
print (x)
+ 1
You:
Used invalid indenting,
Capitalized keyword "if",
Forget a ":" after a block statement.
They seem all to be typing mistakes.