python workourt第一章
预备知识
enumberate
scores = [75, 88, 92, 67, 95, 83, 79]
index = 0
for score in scores:
if score >85:
print(score)
print(index)
index = index + 1
scores = [75, 88, 92, 67, 95, 83, 79]
print("高分榜:")
for index, score in enumerate(scores):
if score >80:
print(f'第{index+1}个学生的成绩是{score}')
我的答案
import random
def guessing_game():
number = random.randint(0,100)
while True:
user_input = input("请输入你的答案:")
if int(user_input)> number:
print("Too high")
elif int(user_input)< number:
print("Too low")
else:
print("Just Right")
break
guessing_game()