how to separate string by comma in python code example
Example 1: split a string by comma python
# We can use the split() function and put a "," in the parameter
# It'll return a list with the string split up by commas.
txt = "hello, my name is Peter, I am 26 years old"
x = txt.split(",")
print(x)
# You can also do this
for thing in x:
print(thing)
Example 2: how to separate a string or int with comma in python
string = input('Input')
>>> 1,2
print(cord.split(','))
>>>['1', '2']