Does array.array only hold real numbers? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Does array.array only hold real numbers?

from array import array x=array('f',('hi','hello')) print(x) #output=TypeError: must be real number,not str.

5th Oct 2018, 4:58 PM
Maninder $ingh
Maninder $ingh - avatar
1 Answer
+ 4
This is also allowed. It is a sample out of the official python documentation: from array import array array('l') array('u', 'hello \u2641') array('l', [1, 2, 3, 4, 5]) array('d', [1.0, 2.0, 3.14])
5th Oct 2018, 5:24 PM
Paul
Paul - avatar