Python String Split() Method

This topic is to discuss the following lesson:

Hi Rene,

as per this eg:
image
'The stored output of the split() method must be this [‘R1’, ‘IOS-XE’, ‘192.168.1.1’] not this one csv_line = “R1,IOS-XE,192.168.1.1”.

please clarify

Hello Pradyumna

If the variable csv_line is a string, then the output of that variable in the window on the right will be of the form “R1,IOS-XE,192.168.1.1”.

If the variable csv_line is a list, then the output of that variable in the window on the right will be of the form [‘R1’, ‘IOS-XE’, ‘192.168.1.1’].

Notice in the following screenshot, initially, the output of csv_line is with quotes, and separated by commas. After it is converted, it appears in square brackets, with each item of the list in single quotes, and separated by commas.

I hope this has been helpful!

Laz