1.while True
luck_num = 19 while True: guess_num = int(input("pls input your guess:")) if guess_num == luck_num: print("binggo") break elif guess_num > luck_num: print("smaller") else: print("bigger")
2.while...else
luck_num = 19 guess_num = 0 while guess_num != luck_num: guess_num = int(input("pls input your guess:")) if guess_num > luck_num: print("smaller") elif guess_num < luck_num: print("bigger") else: print("bingo")
3.for range()
for i in range(3): print(i)
4.continue and break
>>> for i in range(10): ... if i < 5: ... continue ... print(i) ... 5 6 7 8 9 >>> for i in range(10): ... if i == 5: ... break ... print(i) ... 0 1 2 3 4