Python 如何在if函数中打印一些数字?
我必须打印输入的数字,但只能打印用户给出的数字。我不知道该怎么做。我试图做的练习基本上是关于分数的,如果一些分数等于或大于7,我必须打印用户给出的大于或等于7的所有数字。到目前为止,我写的是:Python 如何在if函数中打印一些数字?,python,python-3.x,Python,Python 3.x,我必须打印输入的数字,但只能打印用户给出的数字。我不知道该怎么做。我试图做的练习基本上是关于分数的,如果一些分数等于或大于7,我必须打印用户给出的大于或等于7的所有数字。到目前为止,我写的是: while another == "Yes" : grades = int(input("Add the grade of the student: ")) another = input("Do you want to add another grade? Yes/No: ") 此示
while another == "Yes" :
grades = int(input("Add the grade of the student: "))
another = input("Do you want to add another grade? Yes/No: ")
此示例在输入好成绩时打印好成绩
another = "Yes"
while another == "Yes" :
grades = int(input("Add the grade of the student: "))
if (grades >= 7):
print(grades)
another = input("Do you want to add another grade? Yes/No: ")
此示例在用户完成输入后打印好成绩
another = "Yes"
list_of_grades = []
while another == "Yes":
grades = int(input("Add the grade of the student: "))
if (grades >= 7):
list_of_grades.append(grades)
another = input("Do you want to add another grade? Yes/No: ")
for item in list_of_grades:
print(item)
您可以将它们保存到列表中,以便在执行
时对其进行过滤