我正在创建一个程序,它将接受输入,并在列表中的输入周围输出打开和关闭html标记。显然,下面的代码只会打印上次运行count
次时输入的最后一个输入。我猜想必须在每次传递期间根据count
创建一个新变量。我该如何做到这一点?
runNum = int( input( "How many items are you entering? : "))
print ("Type 1 if you would like to use the li tag or type 2 for the th tag")
descVar = input("")
if descVar == "1":
for count in range ( 1, runNum + 1):
print ("Please enter item #", count, "")
item = input()
for count in range (1, runNum):
print ( <li>, item, </li> )
答案 0 :(得分:0)
只需在列表中收集输入:
items = []
for count in range ( 1, runNum + 1):
print ("Please enter item #", count, "")
item = input()
items.append(item)
for item in items:
print ("<li>",item,"</li>")