PDA

View Full Version : [SOLVED] Chain input in Python



davidcaiazzo
September 19th, 2008, 07:15 PM
I know in python that a input ends with a new line(when the user hits enter). I was wondering if it is possible chain inputs like c++ does. For example:


//c++
string first, last;
cout<<"What is your name(first and last)?";
cin>>first>>last;


In python however I have to do this:


#Python
print "What is your first name?"
first=raw_input()
print "What is your last name?"
last=raw_input()


Is there anyway to chain input?

pmasiar
September 19th, 2008, 07:23 PM
#Python
first, last = raw_input("What is your first and last name?").split()

8-)

davidcaiazzo
September 19th, 2008, 07:32 PM
Thank you!