0

how to add if statement in while loop

13th Jul 2020, 9:10 AM
Rishu Kumar
Rishu Kumar - avatar
5 Answers
+ 1
i = 1 f = False while i < 6 and f == False: i += 1 print(i) if i == 2: f = True
13th Jul 2020, 9:15 AM
Ahmad Shahzad
Ahmad Shahzad - avatar
+ 1
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 thanks for pointing it out. Pretty new to python so didn't know it doesn't support the "&&" and operator and the "++" addition operator. Fixed my code.
13th Jul 2020, 10:04 AM
Ahmad Shahzad
Ahmad Shahzad - avatar
0
i++ can also be written as i += 1
13th Jul 2020, 9:16 AM
Ahmad Shahzad
Ahmad Shahzad - avatar