0
my_list=[]
x=input('Random Word:')
my_list.append(x)
print(my_list)

If i input:

Hi,My,Name,Is,Jeff

The output is:

['Hi,My,Name,Is,Jeff']`

Question: How can i get the output like this`

['Hi','My','Name','Is','Jeff']
Ben Jong
  • 83
  • 5

1 Answers1

0

Use x.split(',')

Refer documentation here: https://www.geeksforgeeks.org/python-string-split/

So your code would look like:

my_list=[]
x=input('Random Word:')
my_list = x.split(',')
print(my_list)
Aragorn
  • 5,021
  • 5
  • 26
  • 37