如何在用户输入为n的情况下运行选定数量的代码

时间:2016-01-31 10:06:11

标签: python python-2.7 python-3.x input output

我在尝试重复代码的某一部分时遇到了一些麻烦,其中n是用户输入。它会从

开始
roominput = int(input("How many rooms do you require painting?"))

然后用户输入integer(n)并且程序的选择部分将重复n次,询问房间名称,房间的尺寸和墙壁的颜色。 / p>

1 个答案:

答案 0 :(得分:0)

你的意思是这样吗?

roominput = int(input("How many rooms do you require painting?"))
for i in range(roominput):
    # ask your questions here, it will be executed roominput times
    # ask room name - room_name = input("What is the room name?")
    # ask room's dimensions - room_dimension = int(input("What is the room's dimensions?"))
    # ask paint for the wall - paint = input("What is the wall paint color?")