124747chdhsgxj
124747chdhsgxj

Reputation: 13

Convert list with one element to list with three elements -Python

How can I convert a list wit one element like this: [[1.0, 0.0, nan]] into a real list with lenght 3

convert `[[1.0, 0.0, nan]]`(lenght=1) into [1.0, 0.0, nan]`(lenght=3)

Upvotes: 0

Views: 396

Answers (2)

Utpal Dutt
Utpal Dutt

Reputation: 403

Simply access the zeroth index of your list which will give you an list of length 3

data=data[0] should do the job

print(data) // [1.0, 0.0, nan]

Upvotes: 0

flakes
flakes

Reputation: 23634

Just access the first value:

a = [[1.0, 0.0, nan]]
b = a[0]

Upvotes: 2

Related Questions