[Tutor] double ended queue
Atux Atux
atuxnull at gmail.com
Sun Nov 5 10:05:04 EST 2017
ok then. how do i link 'r' to remove an item from right with mylist.pop(0)
and how can i remove an item from left with '0r'?
On Sun, Nov 5, 2017 at 11:27 AM, Steven D'Aprano <steve at pearwood.info>
wrote:
> On Sun, Nov 05, 2017 at 10:07:31AM +0200, Atux Atux wrote:
> > Hi. Thanks a lot for the replies. i am actually nw to programming as
> well.
> > your code keeps asking the user for a number and puts it to the end. how
> > can i make it to add a number at the beginning if the user adds 01, then
> > the program it will strip 0 and add 1 at ythe beginning, please?
>
> This sounds like homework. We don't do people's homework for them. What
> have you tried?
>
> Hint: how to tell whether a string ends with "01" or not.
>
> if the_string.endswith("01"):
> print("insert the_string at the beginning")
> else:
> print("append the_string at the end")
>
>
> Second hint. Try running this in the Python interpreter and see what it
> does:
>
> the_string = "1234501"
> the_string = the_string[:-2]
> print(the_string)
>
>
> Third hint: I already showed you how to insert at the beginning, or
> append at the end, of the queue.
>
> We can provide you the pieces of the puzzle, but you have to put them
> together.
>
>
>
> --
> Steve
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list