October 7th, 2004, 10:54 PM
I need help on this code. I have to get 3 numbers from user. start number, end number and count by number. The program is suppose to start with the start number then get up to the end number by adding the count by number to it everytime.
eg. start=3 end=10,count by=2
October 8th, 2004, 02:44 AM
i = start
while i < end:
i = i + count_by
I hope it can help you
October 8th, 2004, 05:27 AM
Don't use a while loop for that, use the range() function, that's what it's for!
start = input('Enter start number: ')
stop = input('Enter stop number: ')
step = input('Enter step number: ')
for counter in range(start, stop, step):
October 8th, 2004, 11:06 AM
Better yet, use the xrange() function instead of range(). That way your program won't bale if your numbers are too big .