1
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()

尝试从 10 数到提供的输入值和 Python 中提供的列,但没有得到它。我基本上想要顶部的 5 个数字,底部的 5 个等。

4

2 回答 2

1
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)

这应该做得很好

于 2020-02-12T02:13:31.790 回答
1

你想要这样的东西吗?

>>> n = 30 # numbers
>>> c = 3 # columns
>>> for i in range(10, n+1):
...     print(i, end='\t')
...     if (i - 10) % c == 0:
...         print()
... else:
...     print()
...
10      11      12
13      14      15
16      17      18
19      20      21
22      23      24
25      26      27
28      29      30

>>>
于 2020-02-12T01:47:05.710 回答