尝试从 10 数到 Python 中提供的输入值和列,但没有得到。我基本上想要 5 个数字在上面等
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()
尝试从 10 数到 Python 中提供的输入值和列数,但没有得到。我基本上想要顶部 5 个数字,底部 5 个数字等
你想要这样的东西吗?
>>> 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
>>>
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)
这样应该就可以了
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 个数字等
你想要这样的东西吗?
>>> 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
>>>
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)
这样应该就可以了