<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#3333ff">
<font size="+1">Or, you could do:<br>
<br>
In [1]: print list(raw_input('name please...'))<br>
name please...John<br>
['J', 'o', 'h', 'n']<br>
<br>
Robert Berman<br>
<br>
<br>
<br>
</font><br>
Kent Johnson wrote:
<blockquote
cite="mid:1c2a2c590902240733l5b385cf1k7676311cc7fba621@mail.gmail.com"
type="cite">
<pre wrap="">On Tue, Feb 24, 2009 at 10:16 AM, Taylan Karaman
<a class="moz-txt-link-rfc2396E" href="mailto:taylankaraman@gmail.com"><taylankaraman@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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']
</pre>
</blockquote>
<pre wrap=""><!---->
Strings behave as sequences of characters, so you can just do
firstname = 'foo'
firstlist = list(firstname)
If you just want to iterate over the letters, there is no need to
create a separate list, you can iterate over the string directly, e.g.
for letter in firstname:
print letter
Kent
_______________________________________________
Tutor maillist - <a class="moz-txt-link-abbreviated" href="mailto:Tutor@python.org">Tutor@python.org</a>
<a class="moz-txt-link-freetext" href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a>
</pre>
</blockquote>
</body>
</html>