Prithviraj Mitra
Prithviraj Mitra

Reputation: 11812

Split tuple into variable using Python

I have the following tuple

res = [('fdetail',), ('fdetail1',)]

I want to have it in two variables using Python

var1 = fdetail

var2 = fdetail1

Any help is highly appreciated.

Upvotes: 0

Views: 310

Answers (1)

ShadowRanger
ShadowRanger

Reputation: 155438

Because you've got a list of one-tuples, you'll need to do a nested unpack:

(var1,), (var2,) = res

Upvotes: 8

Related Questions