string = input('Input') >>> 1,2 print(cord.split(',')) >>>['1', '2']
Here is what the above code is Doing:
1. It’s asking the user to input a string.
2. It’s printing the string.
3. It’s splitting the string into a list of strings.
4. It’s printing the list of strings.
Now let’s try to do the same thing, but this time, we’ll use a for loop:
input_string = input(‘Input: ‘)
for i in input_string.split(‘,’):
print(i)