Archive

Posts Tagged ‘list of strings’

creating a list of strings

February 5, 2017 1 comment

Have you aver written something like this?

>>> li = ["one", "two", "three", "four"]
>>> li
['one', 'two', 'three', 'four']

When I type in all those quotation marks and commas, I always feel sorry for my finger joints. Is there an easier way? Yes, there is:

>>> li = "one two three four".split()
>>> li
['one', 'two', 'three', 'four']
Categories: python Tags: ,