当输入是python时,我想从头开始再次循环此程序

时间:2019-03-22 06:44:31

标签: python

  

某些用途是为某项目输入出价,并且它们具有特定的买方编号。我只能将其循环为一项项目的出价。请帮助我如何通过最后询问用户是否要再次启动该程序寻找另一个项目。

  item_byer=(input("enter the item number 
you want to buy:"))
k=0
for e in (bids_1):
if e==item_byer:
print("item is founded")
break
else:
 print("not founded")
k+=1
index_1=(bids_1.index(item_byer))
price=(bids_1[(index_1)+2])
description=(bids_1[(index_1)+1])
print("the price of the item 
is,",price)
bids=0
bids=price
print("if you want to enter a bid 
please enter this word,bid()")
def bid():
global bids
buyer_num=input("enter your buyer 
number!")
highest=input("enter the bid you want 
to put on this. make sure it is greater 
than previous")
a=0
while int(bids)>int(highest):
  print("bids cannot be transfered it 
should be greater than current 
 highest")
  highest=input("enter your bid again")
  a+=1
 if (bids)<(highest):
  print("bid accepted")
  highest==bids
  print("the current highest bid 
 is",highest)
  bids=highest
  else: 
    print("bid denied it should be 
  greater than the previous")
   quit
   biding=input("if you want to enter a 
   bid enter yes ")
   if biding=="yes":
    bid()
   choice=input("if you want to input 
   another item press yes")

1 个答案:

答案 0 :(得分:2)

由于存在很多问题,但请遵循您最初提出的问题: 我如何才能通过再次询问用户是否要查找其他项目来再次启动该程序。

您可以将您的工作代码循环放置,并在最后接受用户输入,

bids_1 = ['some', 'list', 'of', 'OP']

while True:
    item_ = input("enter the item number you want to buy: ")
    if item_ in bids_1:
        print("item is found")
    else:
        print("item not found")
    userInp = input("Do you want to check for another item? Press Y to continue: ")
    if userInp.upper() != 'Y':
        break