Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
While Loop Problem
#1
Hi,
i'm very very new to python, but familiar with vba, so understand how basics work and in this case a loop.

I have the following code:

i = 1
num_page = 1
bar = progressbar.ProgressBar(max_value=response['meta']['total'], widgets=widgets).start()
print("Total number of records : ", response['meta']['total'])
while i <= response['meta']['total']:
...more code here to retrieve records...

bar.update(i)
        i = i + 1
Run ok, but then I get an error:
Error:
Total number of records : 494 [Elapsed time: 0:06:18] |**********************************| (ETA: 00:00:00) Traceback (most recent call last): File "C:\Users\Admin\Downloads\patients_wip.py", line 118, in <module> bar.update(i) File "C:\Users\Admin\AppData\Local\Programs\Python\Python311\Lib\site-packages\progressbar\bar.py", line 672, in update raise ValueError( ValueError: Value 495 is out of range, should be between 0 and 494 [Elapsed time: 0:06:19] |**********************************| (Time: 0:06:19)
I've tried changing from
while i <= response
to
while i < response

I have made it print at each i, and it will print up to the total number of records.

Any advice and guidance would be greatly appreciated.
Reply


Messages In This Thread
While Loop Problem - by Benno2805 - Sep-06-2023, 03:58 PM
RE: While Loop Problem - by deanhystad - Sep-06-2023, 04:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Loop reading csv file problem faustineaiden 1 1,593 Dec-11-2021, 08:40 AM
Last Post: ibreeden
  Infinite loop problem Zirconyl 5 3,042 Nov-16-2020, 09:06 AM
Last Post: DeaD_EyE
  Dataframe mean calculation problem: do we have to loop? sparkt 1 2,196 Aug-28-2020, 02:41 PM
Last Post: sparkt
  Python loop problem Kristenl2784 11 5,152 Jun-18-2020, 07:22 PM
Last Post: buran
  Problem with append list in loop michaelko03 0 1,707 Feb-16-2020, 07:04 PM
Last Post: michaelko03
  problem with for loop using integers python_germ 5 3,054 Aug-31-2019, 11:42 AM
Last Post: jefsummers
  problem in loop roseojha 3 2,325 Aug-26-2019, 09:03 AM
Last Post: perfringo
  Nested while loop problem + turtle DreamingInsanity 3 3,014 Jul-06-2019, 02:01 PM
Last Post: DreamingInsanity
  Problem Passing Arguement to do loop stephenmolnar 10 4,895 May-13-2019, 02:56 PM
Last Post: Gribouillis
  Nested for loop strange problem mcva 2 2,649 Mar-16-2019, 12:53 PM
Last Post: mcva

Forum Jump:

User Panel Messages

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