Как добавить ввод в массив в python? - PullRequest
0 голосов
/ 06 мая 2020

Я пытаюсь использовать ввод, а затем добавить указанный ввод в конец массива. Это код, с которым я сейчас работаю: Buyers.extend (input ("random string")) Я также пробовал его с .append, но вместо добавления в конец он заменяет то, что сейчас находится в списке, на то, что пользователь ввел. Помогите, пожалуйста. введите описание изображения здесь

Код гласит:

auctionedItem = input("Please enter the name of the item you would like to auction")


def auctioneers():

buyers = []

buyers.append(input("Name the people trying to buy the " + auctionedItem + " : "))

newBuyer = bool(input("Are there more buyers? (yes/NO): "))

if newBuyer == True:
    auctioneers()
elif newBuyer == False:
    print(buyers)
return buyers

аукционисты ()

И ответ гласит

Please enter the name of the item you would like to auction LB&SCR E2 Tank Engine

Name the people trying to buy the LB&SCR E2 Tank Engine : North Staffordshire Railway

Are there more buyers? (yes/NO): yes

Name the people trying to buy the LB&SCR E2 Tank Engine : North Western Railway

Are there more buyers? (yes/NO): yes

Name the people trying to buy the LB&SCR E2 Tank Engine : London & North Eastern Railway

Are there more buyers? (yes/NO): 

['London & North Eastern Railway']
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...