#猜拳机 import random i = 1 while i <= 3: person = int(input('请出拳:[0:石头、1:剪刀、2:布]:')) computer = random.randint(0, 2) if person == 2 and computer == 0: print('胜利!') pass elif person == 1 and computer == 2: print('胜利!') pass elif person == 0 and computer == 1: print('胜利!') pass elif person == computer: print('平局') pass else: print('失败~') pass i += 1 pass
三、for循环
1.遍历容器
1 2 3
for data in range(1, 101): print(data, end = ' ') pass