简体   繁体   中英

TypeError: > not supported between instances of 'int' and 'list'

scores = input("Input a list of student scores\n ").split()
for n in range(0, len(scores)):
  scores[n] = int(scores[n])
print(scores)

# for loop way
highest=0
for s in scores:
   if s > highest:
        highest=scores
print(f"the highest score is {highest}")

please help me how to solve it? I searched it they are saying to add [0] after s example :

for s in scores: if s[0] > highest:



but it did not work and I had the same error

please help me tttttttttttttttttttttttttttttttttttttttttttt

In this line

highest=scores

You are assigning a list ( scores ) to an int var ( highest ), and this is the reason for the error.

I think you have to change the line in

highest=s

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM