Ex33.py while loop functions and input

For the same Ex33 would like to do input but running into issues here is my code:

[code]
print(“Input stop no.”)
stop = input("> “)
print(“Input increment.”)
inc = input(”> ")
i = 0

def number_roll(x, stop_no, increment, numbers):

#i = 0
#numbers = []

while x < stop_no:
    print(f"At the top i is {x}")
    numbers.append(x)

    x += increment
    print("Numbers row: ", numbers)
    print(f"At the bottom i is {x}")

print("The numbers:")

for num in numbers:
    print(num)

number_roll(i, stop, inc, [])
[\code]

Running into this error
[error]
Input stop no.

6
Input increment.
1
Traceback (most recent call last):
File “ex33.1.py”, line 29, in
number_roll(i, stop, inc, [])
File “ex33.1.py”, line 15, in number_roll
while x < stop_no:
TypeError: ‘<’ not supported between instances of ‘int’ and ‘str’
[/error]

Suggestions on how to fix this?
Thank you
Hank

Alright, so the problem is you’re asking the user for input like this:

stop = input("> ")

Now, what input returns ins a string (in Python 3), but when you to try to use it as an integer Python has a problem with that. To fix it you have to convert it to what you really mean:

stop = int(input("> "))

Then it’ll be in the correct type. You can also use float() to create a floating point number.

Hi.
I would do this a little bit different.
Is this something you wanted to achieve?

def stair():

    x = 0
    num = []
    stop_num = int(input('type the stop number please. >: '))
    increment = int(input('type the number of increment to take >: '))
    while x < stop_num:
        print(f'print(num): {x}')
        x += increment
        num.append(x)

        print('number of rows', num)
        print(f'At the bottom x is {x}\n')

    return num

    for i in num:
        print(num)

stair()

The out put would be:
type the stop number please. >: 4
type the number of increment to take >: 1
print(num): 0
number of rows [1]
At the bottom x is 1

print(num): 1
number of rows [1, 2]
At the bottom x is 2

print(num): 2
number of rows [1, 2, 3]
At the bottom x is 3

print(num): 3
number of rows [1, 2, 3, 4]
At the bottom x is 4

Thank you Zed, that was what I was missing in my codes darn “int”. I also incorporated the shorter input method into 1 line.
Thank you
Hank Lee