mrbf
mrbf

Reputation: 522

Decimal keyword in array

To make a list in Django, I use this code:

myList.append([round(x/5),round(y/5,7)])   

The result is:

[510, Decimal('0.0000516')] 

But I need to:

[510, 0.0000516]

How can I solve this problem?

Upvotes: 0

Views: 96

Answers (1)

Brandon Taylor
Brandon Taylor

Reputation: 34573

The type of 0.0000516 in your final list is a float. You can easily convert a Decimal into a float using the built-in float function:

myList.append([float(round(x/5)), float(round(y/5,7))])

Upvotes: 2

Related Questions