Python Forum
Scoping Question: If else in for loop not evaluating i as expected
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scoping Question: If else in for loop not evaluating i as expected
#2
frecords is not necessary as you continually append to frecord. This means that row one is appended to frecords on the first pass. Then row 1 and row 2 are appended to frecords on the second pass, etc., because frecord still has row 1 in it And I assume that this is not all of your code as neither frecord or frecords is declared before the while. Note that you can simplify your code a little with
        if type(cell_value) == type(str()):
            cell_value = cell_value.rstrip()
##            frecord.append(cell_value)
        elif type(cell_value) == type(float()):
            cell_value=int(cell_value)
##            frecord.append(cell_value)
##        else:
        frecord.append(cell_value) 
Reply


Messages In This Thread
RE: Scoping Question: If else in for loop not evaluating i as expected - by woooee - May-11-2018, 05:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Evaluating arithmetic expression with recursion. muddybucket 3 2,886 Dec-17-2021, 08:31 AM
Last Post: deanhystad
  A question about 'Event loop is closed' fc5igm 2 2,267 Oct-05-2021, 02:00 AM
Last Post: fc5igm
Exclamation question about input, while loop, then print jamie_01 5 2,722 Sep-30-2021, 12:46 PM
Last Post: Underscore
  for loop question KEYS 1 1,751 Oct-27-2020, 11:42 PM
Last Post: jefsummers
  Netmiko Loop question sc00ter 2 3,359 Oct-24-2020, 10:54 PM
Last Post: sc00ter
  Please help my while loop does not work as expected KingKhan248 6 2,668 Sep-28-2020, 09:12 PM
Last Post: deanhystad
  while loop question KEYS 2 2,046 Sep-26-2020, 11:02 PM
Last Post: KEYS
  New to programming, loop question tomyan 1 1,673 Sep-25-2020, 04:32 PM
Last Post: Larz60+
  while loop question spalisetty06 2 1,872 Aug-13-2020, 04:18 PM
Last Post: buran
  question about for loop Than999 5 2,525 Jun-09-2020, 02:16 PM
Last Post: Emekadavid

Forum Jump:

User Panel Messages

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