I'm trying to get a better grasp on the data structures. I've been trying to add an array as an element of another array, but i keep getting the TypeError: Array item must be unicode character, when I try to create an array. I'm following videos/everything I read to a T from what i can tell.
from array import array
Swords = array('u',['Steel Sword', 'Bronze Sword', 'Iron Sword'])
Axes = ['Steel Axe', 'Bronze Axe', 'Iron Axe']
Maces = ['Steel Mace','Bronze Mace','Iron Mace']
Bows = ['Wood Bow', 'Bone Bow', 'Obsidian Bow']
Daggers = ['Steel Dagger', 'Bronze Dagger', 'Obsidian Dagger']
Weapons = array('u',([Swords])
for i in Weapons:
print(i)
Any idea what is going on?
'u'type code corresponds to Python’s obsolete unicode character. Why exactly are you trying to use thearraydatatype instead of a normallist?list. Unless you are trying to use a particular function available to thearrayclass, all you'd be doing is adding a constraint to the datatype of the objects inside it.