Ajo Augustine wrote:
hi all;
can u let me know how  to  read an input string  from the keyboard?

In Python 2.6 and lower:

raw_input(prompt)

Example program:

name = raw_input("Enter your name:")
print "Hello", name
raw_input("Press any key to exit.")

In Python 3

Example program:

name = input("Enter your name:")
print ("Hello", name)
input("Press any key to exit.")

The purpose of the last line - when you run the program by double-clicking or equivalent this keeps the window open so you can see the results.

--
Bob Gailer
Chapel Hill NC 919-636-4239

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to