def hailstone(): numbers =  num = input("Enter a number: ") while num != 1: numbers.append(num) if isOdd(num): num = 3 * num + 1 else: num /= 2 if num != 1: print num,"->", else: print num, length = len(numbers) print "; length = ",length
Right now it is prompting for user input inside the function(I don't know if this is the correct way to do it or not). I want to just test it with a range of values that I hardcode, such as 5 to 10. Eventually the starting and ending number in the range need to be entered by the user. This is what I have so far, I cannot think how to get it to work.
def main(): num = 0 for num in range(5, 10): hailstone() main()
It just prompts me for a number 4 times, I need it to automatically print output for numbers 5 through 10. Any help is very much appreciated, thank you!
This post has been edited by mapexx: 23 March 2010 - 08:42 PM