On Sat, Nov 04, 2017 at 10:11:08PM +0200, Atux Atux wrote:

[...]
> i got the starting point where it asks the user and goes until 'q' is
> pressed.
> 
> while True:
>     if input("\n\n\nType  a number to add it to the queue or q to
> exit: ") == 'q':
>         break
> 
> but i a stuck on how to continue asking and adding to the list

To start with, you have to actually have a list to add to.

queue = []

To add to the left of the queue, use:

queue.insert(0, value)

To add to the right of the queue, use:

queue.append(value)

To delete the first value:

del queue[0]

and to delete the last:

del queue[len(queue)-1]



-- 
Steve
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to