Skip to content
Advertisement

input to choose how many reuslts to generate [closed]

I have this code for i in range(1111111111111111, 9999999999999999): print(i) I want to give an input which user will select how much value will the program generate. like if he want only to generate 5k numbers it will only generate 5k. what to do!

Advertisement

Answer

You can do it like this:

a = 1111
b = 9999

num = 500 # how many values you want
for i in range(a, b):
    if i >= a + num:
        break
    print(i)
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement