Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If statement not working
#2
The problem is that "number" is a string. The input function returns a raw string of the user input. Python cannot compare strings and numbers (e.g. "5" != 5). To correct this, you can change line 12:

number = int(input(' Enter line #  : '))
Reply


Messages In This Thread
If statement not working - by oldcity - Oct-09-2018, 11:57 PM
RE: If statement not working - by stullis - Oct-10-2018, 12:39 AM
RE: If statement not working - by micseydel - Oct-10-2018, 12:41 AM
RE: If statement not working - by buran - Oct-10-2018, 06:48 AM
< SOLVED >RE: If statement not working - by oldcity - Oct-14-2018, 10:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question If, elif, and else statement not working PickleScripts 3 982 Mar-30-2023, 02:53 PM
Last Post: PickleScripts
  If statement not working correctly? MrKnd94 2 887 Nov-16-2022, 02:49 AM
Last Post: deanhystad
  If Statement not working...Why? Milfredo 2 2,274 Oct-17-2020, 03:23 AM
Last Post: Milfredo
  Invoking function in if else statement, not working! ibaad1406 13 5,840 May-30-2019, 09:05 PM
Last Post: ibaad1406
  if statement not working trent101010 8 5,135 Mar-14-2018, 03:19 PM
Last Post: wavic
  why is this try.....except statement not working? HenryJ 3 8,849 Feb-06-2018, 06:15 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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