python - 尝试从 10 数到提供的输入值和 Python 中提供的列,但没有得到它。我基本上想要5个数字等
问题描述
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 个等。
解决方案
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)
这应该做得很好
推荐阅读
- php - Codeigniter 4 软删除仍在删除数据库记录
- batch-file - 批量复制
- jestjs - jest 可以在测试运行中包含快照,但排除对代码覆盖的贡献吗?
- firebase - 通过按后退按钮关闭应用程序时,Flutter Foreground Service 无法正常工作
- java - 区域设置在android studio Emulator中成功更改,在使用应用程序时在实际设备中没有更改
- java - RecyclerView 项目不重复,但保留其插槽中先前项目的更改
- python - 在 PyTorch 中屏蔽损失函数的最合适方法是什么
- javascript - 我有与内容安全政策相关的问题
- python - 来自同一对象的 2 个不同引用对来自同一类的两个不同对象 - DJANGO 数据库
- javascript - Javascript Promise - 带返回值的递归 - “记住层次结构”