Reputation: 3070
I have a text likes
input = ID-name-birth
I want to extract the ID, name and birth separately. So I used
ID= input.split('-')[0]
name= input.split('-')[1]
birth = input.split('-')[2]
It worked. But sometimes, my customer insert likes
input = ID_name_birth
So I need to change the code to
ID= input.split('_')[0]
name= input.split('_')[1]
birth = input.split('_')[2]
I want to make my code work any situation wherever insert '_' nor '-'. Do we have an option to deal with the problem?
Upvotes: 0
Views: 46