pythonpython-3.xspyderjuniper

Trying to count from 10 to the input value provided and columns provided in Python but not getting it. I basically want like 5 numbers on top etc


counter = 10
numbers = int(input("Enter a number between 10 and 99: "))
column = int(input("How many columns would you like? "))
for num in range(10, numbers):
    for col in range(column):
        counter += 1
    print(num + 1, end= ' ')
print()

Trying to count from 10 to the input value provided and columns provided in Python but not getting it. I basically want like 5 numbers on top, 5 on bottom etc.


Solution

  • counter = 10
    numbers = int(input("Enter a number between 10 and 99: "))
    column = int(input("How many columns would you like? "))
    output_string = ""
    
    col_counter = 0
    while (counter <= numbers):
        output_string += str(counter)+" "
        counter += 1
        col_counter += 1
        if(col_counter == column):
           print(output_string)
           output_string=""
           col_counter = 0
    print(output_string)
    

    This should do it just fine