Python Forum
If Statement not working...Why?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If Statement not working...Why?
#1
Here is a snippet of code and what it produces. I don't understand what is going on.

def complete_form():
	
	horses_names = []
	for i, var in enumerate(scratched):    
		scratched_list.append(var.get())   	
		
	
	for a in range(len(scratched_list)):
		if scratched_list[a] == 'True':
			print(horses_name[a])
		else:
			print(scratched_list[a])
Here is what it prints out. As you can see there is one condition that is True, but the code doesn't seem to recognize it. I don't know why. Where scratched_list[a] == 'True' horses name should appear, but I get 'True' instead.

$ python processing.py
False
False
True
False
False
False
Reply


Messages In This Thread
If Statement not working...Why? - by Milfredo - Oct-17-2020, 12:24 AM
RE: If Statement not working...Why? - by perfringo - Oct-17-2020, 12:39 AM
RE: If Statement not working...Why? - by Milfredo - Oct-17-2020, 03:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question If, elif, and else statement not working PickleScripts 3 937 Mar-30-2023, 02:53 PM
Last Post: PickleScripts
  If statement not working correctly? MrKnd94 2 854 Nov-16-2022, 02:49 AM
Last Post: deanhystad
  Invoking function in if else statement, not working! ibaad1406 13 5,697 May-30-2019, 09:05 PM
Last Post: ibaad1406
  If statement not working oldcity 4 3,133 Oct-14-2018, 10:45 AM
Last Post: oldcity
  if statement not working trent101010 8 5,022 Mar-14-2018, 03:19 PM
Last Post: wavic
  why is this try.....except statement not working? HenryJ 3 8,792 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