Monday, January 7, 2008

How To Give Input From Console In Python ?


The answer to this frequent question of beginners:

name = raw_input()
print name


If you want to read an integer -

num = raw_input()
num = int(num)
# raw_input returns string, so convert it to integer

No comments:

Post a Comment