Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

unsupported operand type(s) for -: 'str' and 'str' for number game [duplicate]

$
0
0

I am a newbie at Python and i need help. I don't understand what to do no matter what this code won't work. I am trying to make a hotter colder number game.

import mathimport randomanswer = str(random.randint(1, 1000))guess = input('take a guess\n') # \n ---> newline  ---> It causes a line breakif abs(guess - answer) <= 250:  print("You're warm!")elif abs(guess - answer) <= 100:  print("You're getting warmer.")elif abs(guess - answer) >= 250:  print("You're cold."else:  print("You're freezing.")

I've tried everything I know please help.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>