type error: can't use - for list or integer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

type error: can't use - for list or integer

what i can do for this code? https://code.sololearn.com/cpj40S46B1WC/?ref=app

1st Feb 2019, 2:04 AM
Ahmad Ali
Ahmad Ali - avatar
5 Answers
+ 3
https://docs.python.org/3/library/sqlite3.html Yes execute(SELECT) returns a list, even though by fixing id as 1 there is only one entry.
1st Feb 2019, 7:25 AM
Gordon
Gordon - avatar
+ 4
it turns out that select produces list of dictionaries. so a =a[i] ["key"] and its worked, thank you all. Gordon Maninder $ingh thank you very much
1st Feb 2019, 4:23 PM
Ahmad Ali
Ahmad Ali - avatar
+ 2
I think when you define c variable then something is wrong please check your code again.
1st Feb 2019, 2:43 AM
Maninder $ingh
Maninder $ingh - avatar
+ 2
print(type(a)) If a is list Use a[0] to get the number first, then type cast to float
1st Feb 2019, 7:19 AM
Gordon
Gordon - avatar
+ 1
a = float(a) c = float(c)
1st Feb 2019, 4:35 AM
Gordon
Gordon - avatar