Answers for "python make string list"

37

convert string to list python

# To split the string at every character use the list() function
word = 'abc'
L = list(word)
L
# Output:
# ['a', 'b', 'c']

# To split the string at a specific character use the split() function
word = 'a,b,c'
L = word.split(',')
L
# Output:
# ['a', 'b', 'c']
Posted by: Guest on February-18-2020
2

how to make a list string in python

n = ["Hello"," I'm " , "12" , " Years Old "] # Our list
String = "" # Our string
for x in n :
    String += x
    
print(String) #Prints it
Posted by: Guest on March-05-2021
0

python3 create list from string

input = ['word1, 23, 12','word2, 10, 19','word3, 11, 15']
output = []
for item in input:
    items = item.split(',')
    output.append([items[0], int(items[1]), int(items[2])])
Posted by: Guest on September-16-2020

Python Answers by Framework

Browse Popular Code Answers by Language