Reputation: 11
I want to make a program in which i input a string then make it into list and then use list.count. To do this i need list without colons.
a=("44, 4, 5, 6, 7, 8 ")
a=[a]
print(a)
-> ['44, 4, 5, 6, 7, 8 ']
but i want this:
[44, 4, 5, 6, 7, 8]
i tried this:
b=map(int, a)
print(b)
but then get this ->
<map object at 0x00537810>
and don't know what to do next
Upvotes: 0
Views: 4641
Reputation: 37163
It's even easier than that:
>>> a=("44, 4, 5, 6, 7, 8 ")
>>> my_list = [int(s) for s in a.split(", ")]
>>> my_list
[44, 4, 5, 6, 7, 8]
>>>
Upvotes: 4