Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if clause fails
#1
OK, this shouldn't be that hard but maybe I'm missing something.

This is the full function, the problem lies between the ###########################################################################s.
If anyone wants to see the full code I'll upload, but it seems pretty clear to me it's not the issue, but hell I'm a self taught coder so maybe I'm wrong. Someone please let me know if I'm doing something wrong or if it's a stupid bug and I should redo it in another coding language. Also I'm using Python 2.7.1 and the Idle IDE for windows 10.

Edit: Noticed a strange indentation in that exact section after uploading code, gonna go fix that quick.

def GetCards():

    commonList = [];
    uncommonList = [];
    rareList = [];
    common1 = '';
    common2 = '';
    common3 = '';
    common4 = '';
    common5 = '';
    uncommon1 = '';
    uncommon2 = '';
    uncommon3 = '';
    rare = '';
    commonSet1 = '';
    commonSet2 = '';
    commonSet3 = '';
    commonSet4 = '';
    commonSet5 = '';
    uncommonSet1 = '';
    uncommonSet2 = '';
    uncommonSet3 = '';
    rareSet = '';
    complete = 0;
    commonPrice1 = 0.00;
    commonPrice2 = 0.00;
    commonPrice3 = 0.00;
    commonPrice4 = 0.00;
    commonPrice5 = 0.00;
    uncommonPrice1 = 0.00;
    uncommonPrice2 = 0.00;
    uncommonPrice3 = 0.00;
    rarePrice = 0.00;
    maxValue = 0.00;
    packValue = 0.00;
	
	
    while complete != 2:
        
        complete = 0;
        
        #need to find how to get a username and match it to a name in a database
        #need to check if user has any spins before enabling the spin button
        #need to attach a paypal payment so user can add 1-2 more spins
	collection = importCollection();
	
	for i in range(10):
###########################################################################################################################################
            print(collection[i].qty);  <---- This outputs the correct values
            if collection[i].qty < 5: <---- This doesn't care
                print(len(collection)); <---- Never prints regardless of collection[i].qty
##########################################################################################################################################
                #for j in range(i + 1, len(collection)):
                    #collection[j - 1] = collection[j];
                    #collection = collection[:1];

        print(len(collection));                
        lngListCounter = 0
        for lngRecordCounter in range(len(collection)):
            if collection[lngRecordCounter].rarity == 'C':
                commonList.append(collection[lngRecordCounter]);
                lngListCounter += 1;
        lngListCounter = 0
        for lngRecordCounter in range(len(collection)):
            if collection[lngRecordCounter].rarity == 'U':
                uncommonList.append(collection[lngRecordCounter]);
                lngListCounter += 1;
        lngListCounter = 0
        for lngRecordCounter in range(len(collection)):
            if collection[lngRecordCounter].rarity == 'R' or collection[lngRecordCounter].rarity == 'M':
                rareList.append(collection[lngRecordCounter]);
                lngListCounter += 1;

        print(commonList[2].name);
        print(len(commonList));
        print(uncommonList[2].name);
        print(len(uncommonList));
        print(rareList[2].name);
        print(len(rareList));
        complete = 2;

Well I tried a change that should have done it but...
for i in range(10):
		  num = collection[i].qty;
		  print(num); <---- Again it prints the correct value so there is no uncertainty of what the if clause is looking for
		  if num < 5: <---- Using num which has a set value still fails to trigger the if clause
			print(len(collection)); <---- Still never prints
Reply


Messages In This Thread
if clause fails - by DeadCthulhuWaitsDreaming - Apr-07-2019, 06:38 PM
RE: if clause fails - by Yoriz - Apr-07-2019, 07:12 PM
RE: if clause fails - by DeadCthulhuWaitsDreaming - Apr-07-2019, 07:29 PM
RE: if clause fails - by ichabod801 - Apr-07-2019, 07:30 PM
RE: if clause fails - by DeadCthulhuWaitsDreaming - Apr-07-2019, 07:34 PM
RE: if clause fails - by ichabod801 - Apr-07-2019, 07:46 PM
RE: if clause fails - by DeadCthulhuWaitsDreaming - Apr-07-2019, 08:08 PM
RE: if clause fails - by ichabod801 - Apr-07-2019, 08:13 PM
RE: if clause fails - by DeadCthulhuWaitsDreaming - Apr-07-2019, 08:20 PM
RE: if clause fails - by ichabod801 - Apr-07-2019, 08:24 PM
RE: if clause fails - by DeadCthulhuWaitsDreaming - Apr-07-2019, 09:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to use the LIKE clause in Python Columbo 9 1,620 Oct-09-2022, 10:22 PM
Last Post: Larz60+
  SQL Query is not executing WHERE clause hammer 7 2,329 Nov-15-2021, 01:44 PM
Last Post: hammer
  How does this if clause work? Pedroski55 3 2,272 Jun-10-2021, 06:31 AM
Last Post: Gribouillis
  can i raise an exception in a try clause? Skaperen 14 5,725 Dec-19-2019, 12:29 AM
Last Post: Skaperen
  pass captured value from input() to where clause metro17 5 3,267 Sep-09-2019, 05:24 AM
Last Post: metro17
  finally clause Skaperen 6 3,874 Jun-02-2019, 09:02 PM
Last Post: snippsat
  how to code in Python "where" clause of SAS FelixS 2 2,787 Mar-26-2019, 04:59 PM
Last Post: FelixS
  break Statements and else Clause on Loops Phytonnewbie 2 2,789 Mar-02-2018, 09:50 AM
Last Post: buran
  My else clause doesn't work (general help) NMW 10 7,912 Jul-17-2017, 01:07 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