Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

Listing item in input when slash comes in python ?

By M.K. Verma · 3 May 2022

Listing item in input when slash comes in python ?

The split() method is useful in cases like this. You can split first on /, and then split the resulting elements on ,.

line = '1,2,3/4,5,6/7,8,9,10/11'
[x.split(',') for x in line.split('/')]