Homework python problem

A forum for general discussion of the Python programming language.

Homework python problem

Postby masterpiece » Thu Apr 17, 2014 8:07 am

hello i have a question about this python program, i dont understand how does that append fucntion works, i know that first if i>0 will be used but dont understand how does that part with i-1 works, i have tried changing it to i-2 and other numbers but i couldnt find any explenation for how does it works, for result i get 0 1 0, so i hope someone cand find few moments of their time to explane me that, thanks.
http://imgur.com/NVRZ0fV
Last edited by Mekire on Thu Apr 17, 2014 8:26 am, edited 1 time in total.
Reason: First post lock.
masterpiece
 
Posts: 1
Joined: Thu Apr 17, 2014 8:06 am

Re: Homework python problem

Postby Mekire » Thu Apr 17, 2014 8:28 am

Read this carefully.
Then come back and post your code in code tags please.
Then we can try to help you.

Also, while crossposting is not a crime, simultaneously posting your question in three major Python forums (at least) is not going to endear you to anyone. If you had spent the time on writing your post that you spent on crossposting, you'd have your answer by now.

-Mek
User avatar
Mekire
 
Posts: 988
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Homework python problem

Postby Somelauw » Thu Apr 17, 2014 11:21 am

masterpiece wrote:hello i have a question about this python program, i dont understand how does that append fucntion works, i know that first if i>0 will be used but dont understand how does that part with i-1 works, i have tried changing it to i-2 and other numbers but i couldnt find any explenation for how does it works, for result i get 0 1 0, so i hope someone cand find few moments of their time to explane me that, thanks.
http://imgur.com/NVRZ0fV


An image makes it harder for us to help you, because we can't copy-paste an image in our own editors to see what happens when the code is run.
More good advice about how to post, can be found in the link that Mekire posted.

You seem to have trouble understanding how lists work.
Maybe you should read this: http://learnpythonthehardway.org/book/ex32.html
Join the #python-forum IRC channel on irc.freenode.net!
Somelauw
 
Posts: 71
Joined: Tue Feb 12, 2013 8:30 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests