Python Forum
Need help with this code and am stuck
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with this code and am stuck
#2
input() function will return a string which you have entered. So even if you enter number 5, it will be stored as a string variable, not an int. That is why in this line:
if 0 <= num < 100:
you compare integers to a string (num). For this code to work, you need to first convert the number from string to integer type:
num = int(input("Enter a number: "))
Reply


Messages In This Thread
RE: Need help with this code and am stuck - by j.crater - Sep-19-2019, 07:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have homework that I've made no effort to show any code that I'm stuck on Ronaldinho 1 2,430 May-30-2019, 07:18 PM
Last Post: nilamo
  Trying to teach myself how to code and I'm stuck on a question I found online... abushaa4 1 2,267 Dec-16-2018, 01:52 PM
Last Post: ichabod801
  stuck in a block of code fadi 1 2,966 Aug-26-2017, 02:26 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020