[Tutor] String to list conversion

Emad Nawfal (عماد نوفل) emadnawfal at gmail.com
Tue Feb 24 16:21:38 CET 2009


On Tue, Feb 24, 2009 at 10:16 AM, Taylan Karaman <taylankaraman at gmail.com>wrote:

> Hello,
>
> I am a beginner. And I am trying to get a user input converted to a list.
>
> print 'Enter your first name :'
> firstname = raw_input()
>
> So if the user input is
>
> firstname = 'foo'    ----------->should become-------->
> firstlist['f','o','o']
>
>
> thanks in advance
>
if I understand this correctly, you want a name like "foo" to be changed to
['f', 'o','o']
This is what the list function does. for example,
>>> name = "foo"
>>> list(name)
['f', 'o', 'o']
>>>


> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.....محمد
الغزالي
"No victim has ever been more repressed and alienated than the truth"

Emad Soliman Nawfal
Indiana University, Bloomington
http://emnawfal.googlepages.com
--------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090224/e3329128/attachment.htm>


More information about the Tutor mailing list