User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 456,488 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,738 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 480 | Replies: 1
Reply
Join Date: Sep 2007
Posts: 1
Reputation: bd1234 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bd1234 bd1234 is offline Offline
Newbie Poster

any tips on how to get the program to display the first name in the final print strin

  #1  
Sep 12th, 2007
name = raw_input("What is your name (Last, First)?")
first = name.find(', ')
print "Hi", first, "!!!"
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 27
Reputation: StrikerX11 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
StrikerX11 StrikerX11 is offline Offline
Light Poster

Re: any tips on how to get the program to display the first name in the final print s

  #2  
Sep 13th, 2007
>>> name=raw_input("Enter your name [first, last]")
Enter your name (first, last): FIRST, LAST
>>> List=name.split(', ') #name='FIRST, LAST'
>>> List
['FIRST', 'LAST']
>>>print "Hi, ", List[0] # print first
OR
>>> index=name.find(',') #First occurance of the comma
>>> first=name[0:index]
>>> first
'FIRST'
Last edited by StrikerX11 : Sep 13th, 2007 at 12:53 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 3:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC