Write a program to take an input, add it to the end of the queue and output the resulting list. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 5

Write a program to take an input, add it to the end of the queue and output the resulting list.

You are working on a queue management program. The queue is represented by a list. Note: The append() method can be used to add new items to the list. Program: queue = ["John", "James", "Amy"] txt = input() #your code goes here L= queue.append(txt)?

12th Aug 2021, 8:07 AM
Shree Harini
Shree Harini - avatar
19 Answers
+ 7
queue = ["John", "James", "Amy"] txt = input() queue.append(txt) print(queue) Enjoy!
19th Aug 2021, 7:51 PM
Alex Kondratyk
+ 7
Shree Harini Attempts please? Check Notes: given in practice
12th Aug 2021, 8:12 AM
A͢J
A͢J - avatar
+ 7
Check lesson again and know how to add new data in list. Check examples given in lesson. If you still didn't get then take help from Google..
12th Aug 2021, 8:51 AM
A͢J
A͢J - avatar
+ 5
Shree Harini Why don't you try solving the simple stuff and attempt the difficult stuff after you have developed your skills a bit morr
12th Aug 2021, 9:09 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 4
Hey Shree Harini please try solving that if you haven't. And after solving, post your code here. And then if you have problem then ask it here. Thanks
12th Aug 2021, 10:30 AM
Parth
Parth - avatar
+ 3
I'm a beginner. Thought of giving a try to solve a problem! But, I'm unable to solve it
12th Aug 2021, 8:17 AM
Shree Harini
Shree Harini - avatar
+ 3
Hi Shree! You look pretty close! But, the thing is that you have to recall your knowledge about list functions. I can give you a small example to understand the function of append(). Let's say we have a list named, x. x = [1,2,3]. If you want to add an element(4) at the end of the list x, this is the way you have to follow. x.append(4) Finally, you can print your updated list by using print statement as always. print(x) Output: [1,2,3,4]
12th Aug 2021, 3:04 PM
Python Learner
Python Learner - avatar
+ 3
queue = ['John', 'Amy', 'Bob', 'Adam'] txt = input() queue.append(txt) print(queue)
1st Jun 2022, 8:54 PM
Роман Бойчук
Роман Бойчук - avatar
+ 2
24th Feb 2022, 9:38 AM
stephen mazola
stephen mazola - avatar
+ 1
чтобы понять команду .append(), при решении этой задачи необходимо вспомнить что мы уже знаем о списках. Пример, Допустим, у нас есть список с именем x. х = [1,2,3]. Если мы хотим добавить еще один элемент ( например цифру "4") в конец этого списка (списка х = [1,2,3]), мы должны сделать следующее: х.append(4) и наш код станет выглядеть так: x = [1,2,3] х.append(4) теперь добавим команду вывода на экран (print(x)) и получим уже обновленный (дополненный новым элементом в конце списка) список x = [1,2,3] х.append(4) print(x) получим: 1,2,3,4
8th Jan 2022, 8:34 PM
Ihor Princ
Ihor Princ - avatar
+ 1
Queue = ['India','USA','China'] Now ,if you want to add one more country in this queue - you should use function called -append(). So, just get input from user like, txt=input() x=queue.append(txt) print(x) 😊
15th Apr 2022, 5:56 PM
Krupesh Rajendrakumar Desai
+ 1
queue = ['John', 'Amy', 'Bob', 'Adam'] name=input() queue.append(name) print(queue)
24th Oct 2022, 6:36 PM
Syed Arsh Farooqui
Syed Arsh Farooqui - avatar
0
my solution is: queue = ["John", "James", "Amy"] txt = input() queue.append(txt) print(queue)
8th Jan 2022, 8:21 PM
Ihor Princ
Ihor Princ - avatar
0
queue = ['John', 'Amy', 'Bob', 'Adam'] txt = input() queue.append(txt) print(queue) DONE...!
5th Mar 2022, 4:06 PM
Nikhila
0
queue = ['John', 'Amy', 'Bob', 'Adam'] name = input() queue.append(name) print(queue)
28th May 2022, 11:38 AM
Evgen Shamanayev
Evgen Shamanayev - avatar
0
queue = ['John', 'Amy', 'Bob', 'Adam'] txt = input() queue.append(txt) print(queue)
4th Jun 2022, 6:30 PM
Big Brain Plays
0
Question: You are working on a queue management program. The queue is represented by a list. Write a program to take an input, add it to the end of the queue, and output the resulting list. Answer: queue = ['John', 'Amy', 'Bob', 'Adam'] item = input() queue.insert(4, item) print(queue) OR queue = ['John', 'Amy', 'Bob', 'Adam'] item = input() queue.append(item) print(queue)
29th Aug 2022, 6:13 AM
Lawal Akinola
0
txt = input() queue.append(txt) print(queue)
14th Oct 2022, 5:15 AM
Sumit Prajapati
Sumit Prajapati - avatar
0
queue = ['John', 'Amy', 'Bob', 'Adam'] name = input() queue.append(name) print(queue)
19th Mar 2023, 7:28 PM
المهندس أحمد
المهندس أحمد - avatar