>From what I can understand, I think you are getting what you should get. If you want the program to ask you for a number onput, i think you should type something like: x = raw_input('Enter a Number: ') x is a variable that takes whatever value you type in. This I feel should be the line if you are on python 3 and I should even ask why. I got the same advice as a beginner to learn with python 2.6 due to availability of books and tutorials. However, if it were python 2.6, type: x = input('Enter a Number: ') Here, x also takes any value you enter. Clearly, from what you have shown here, you should get something like: 24 Hello Greetings Earthing Hello Greetings Earthing Hello Greetings Earthing Hello Greetings Earthing Hello Greetings Earthing Hello Greetings Earthing Here's the explanation: The greeting functions if called should have given this: Hello Greetings Earthing Hello Greetings Earthing I iterates over the print call 2 times because you stated range(3) However, you called the greeting function in the regreet function, and stated that j should iterate in the range(4). That way, greeting is called 3 times and then you have what i have already stated above. I hope this is correct and it helps. Regards.
On 9/3/10, Colleen Glaeser <songbird42...@gmail.com> wrote: > Dear Python Tutors, > > I'm having trouble while typing a beginner program for python. > Due to troublesome circumstances, I had to take pictures of the assignment > sheet on my phone, and work from that. > Although it is all clearly legible, I still think something with my program > is not working. > > If I run the program in the shell, I should be getting something that asks > for a number, and I need to try positive and negative numbers and see what > spits out. > > However, I'm getting the number 24, and a repetition of the words "Hello" > and "Greetings, earthlings." > > This below is my program, and I've retyped it too many times to remember, > while looking at the assignment sheet. > What am I doing wrong? Can anybody help? D: I need to turn my results in > to class tomorrow morning! > > # Lab 1 > # Programmed by Colleen G. > > x = 12 > > print (2*x) > > def greetings(): > for i in range (3): > print ('Hello ') > print ('Greetings, earthling') > > def regreet(): > for j in range(4): > greetings() > > regreet() > > > End of program.....help needed quickly! Thank you! I am using Python 3.1.2 > > -- > Colleen Glaeser > songbird42...@gmail.com > 636.357.8519 > -- Sent from my mobile device Elegbede Muhammed Oladipupo OCA +2348077682428 +2347042171716 www.dudupay.com Mobile Banking Solutions | Transaction Processing | Enterprise Application Development _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor