python - Read input and output the results out -


how code out in python such when user type 3, system output 3 ^? example,

userinput: 3 system: ^^^ userinput: 4 system: ^^^^ 

am supposed use loop , loop on it? im new python, please help. thanks!

in simplest form:

from_input = raw_input() print int(from_input) * '^' 

this parse incoming string integer. however, note here if put else string can parsed raise valueerror.

a safer approach be

from_input = raw_input() try:    int(from_input) * '^' except valueerror:    print "can't cast {0} int".format(from_input) 

Comments