Python给我的是索引号,而不是列表中的输入。
Python给我的是索引号,而不是列表中的输入。我试图让用户提供输入,然后让它将其存储到打印的列表中。我该怎么修Python给我的是索引号,而不是列表中的输入。,python,list,Python,List,Python给我的是索引号,而不是列表中的输入。我试图让用户提供输入,然后让它将其存储到打印的列表中。我该怎么修 number_of_grades = int(input('How many quizzes have you had?')) grade_list = [] for grades in range(number_of_grades): input('Please input a grade from the quiz.') grade_list.insert(0
number_of_grades = int(input('How many quizzes have you had?'))
grade_list = []
for grades in range(number_of_grades):
input('Please input a grade from the quiz.')
grade_list.insert(0, grades)
print(grade_list)
它在需要打印之前工作正常。这是因为您没有将第二个输入指定给变量!,然后,您只需插入
for
循环中使用的索引
number_of_grades = int(input('How many quizzes have you had?'))
grade_list = []
for grades in range(number_of_grades):
value = input('Please input a grade from the quiz.')
grade_list.insert(0, value)
print(grade_list)
这是因为您没有将第二个输入指定给变量!,然后,您只需插入
for
循环中使用的索引
number_of_grades = int(input('How many quizzes have you had?'))
grade_list = []
for grades in range(number_of_grades):
value = input('Please input a grade from the quiz.')
grade_list.insert(0, value)
print(grade_list)
您认为第二个
输入返回的值会发生什么变化?您认为第二个输入返回的值会发生什么变化?非常感谢!我一辈子都想不出来。太好了!!,这在我身上经常发生。很高兴帮助你。非常感谢!我一辈子都想不出来。太好了!!,这在我身上经常发生。很高兴帮助你。