"def spam(n=3): """Return n slices of yummy spam.""" return "spam "*n
And here it is in use: >>> spam(4) 'spam spam spam spam ' >>> spam() # just use the default 'spam spam spam ' Can you see what I did to set the default value for n? Read the function definition line "def spam... " carefully. -- Steven" This is my new code for a default step value based on your feedback Steve: def ask_number(question, low, high, step): """Ask for a number within a range.""" response = None if step == None: step = 1 while response not in range(low, high, step): response = int(input(question)) return response
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor