"Colleen Glaeser" <songbird42...@gmail.com> wrote

Although it is all clearly legible, I still think something with my program
is not working.

Why, can you explain what you think should happen?

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.

Where do you think your code asks for a number?

However, I'm getting the number 24, and a repetition of the words "Hello"
and "Greetings, earthlings."

That seems to be what your code prints so it would appear to be reasonable.

What am I doing wrong? Can anybody help? D: I need to turn my results in
to class tomorrow morning!

x = 12
print (2*x)

Here is your 24

def greetings():
   for i in range (3):
       print ('Hello ')
   print ('Greetings, earthling')

And this repeatedly prints Hello and Greetings Earthling

def regreet():
   for j in range(4):
       greetings()

And this calls greetings() repeatedly, so even
more printing of the messages.

regreet()

And this actually calls regreet() which triggers the whole thing off.

So your code appears to be doing exactly what you told it to do.
Where should the reading of numbers come in?
And what would you do with the numbers when you got them?

You might find the "Talking to the user" topic of my tutorial useful.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


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

Reply via email to