How to get a tuple from string upto nth occurence of separator


Joined
Dec 5, 2020
Messages
1
Reaction score
0
a = "Nople Normal Altar1-truck-Altar2,Altar2-train-Cansomme,Cansomme-flight-Karoh,Karoh-truck-Nople"

x= tuple(a.split(' '))
print(x)

I want the output tuple to be as below :

x= ( Nople , Normal)
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top