简体   繁体   中英

I am getting an error message whenever I try and run this

score = input("what you score bro: ")
if score > 1000:
  print("winner")
else:
  print("loser")

(I am a complete noob). Idk why im getting an error looks right to me.

I tried it on my own then I watched the video again and looked at the bald guys code and mine looks the same idk whats wrong

It's not a well-formulated question, but that doesn't mean newcomers shouldn't be helped out. Python relies on proper spacing.

If that's not your issue, you need to know that python will take input as a string, so you need to cast it explicitly to an integer

The following will work. Note the spacing and the explicit cast to an integer type:

score = input("what you score bro: ")
score = int(score)
if score > 1000:
    print("winner")
else:
    print("retard")

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