How can I turn an inputed string into a list in python? -
how can have user enter string , have string made list? have tried following code:
original=input("enter message encode: ") originallist = list(original) print originallist
i keep getting error though:
nameerror: name 'whatever input' not defined
i don't understand mean, if want whole string put inside list, do:
a = list(raw_input())
or
a = [raw_input()] # `split()` can take argument — character (or string) @ split # i.e.: "jim , tim; bob , rob".split(";") -> ["jim , tim", "bob , rob"]
if wanted string split tokens, use built-in split
method.
a = raw_input().split()
note: of course, python 3, raw_input()
replaced input()
.
hope helps! :)
Comments
Post a Comment