Hello All, I am working with Python tutorial in wiki and one of the exercises is as follows:
Ask the user for a string, and then for a number. Print out that string, that many times. (For example, if the string is hello and the number is 3 you should print out hellohellohello.) Solution for this exercise is: text = str(raw_input("Type in some text: ")) number = int(raw_input("How many times should it be printed? "))print (text * number) Since in Python raw_input() function was renamed to input() according to PEP 3111 <http://www.python.org/dev/peps/pep-3111/> I have respectively updated this code to: text = str(input("Type in some text: ")) number = int(input("How many times should it be printed? "))print (text * number) However when I try to execute this code in Python 3.1 interpreter error message is generated: Type in some text: some How many times should it be printed? 3 Traceback (most recent call last): File "test4.py", line 2, in <module> number = int(input("How many times should it be printed? ")) ValueError: invalid literal for int() with base 10: 'How many times should it be printed? 3' Can you please advise me how to resolve this issue?
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor