20 Aug Wednesday Friday 15:00 Python Practice 20.08.19.
Question:
- Create a list called “attributes” , it contains “HP”, “Attack”, “Defense”, “Special Attack”, “Special Defense”, “Speed”
- Modify the list above, replace “Special Attack” and “Special Defense” with “Magic” and “Stamina”
- Add “Special skills” in the end of the list
- Delete “Speed” from the list.
- Insert “Special Attack” and “Special Defense” just before “Special skills”
Jesse Shi
Posted at 18:26h, 21 Augustattributes = [“HP”, “Attack”, “Defense”, “Special Attack”, “Special Defence”, “Speed”]
print (attributes)
[‘HP’, ‘Attack’, ‘Defense’, ‘Special Attack’, ‘Special Defence’, ‘Speed’]
(attributes.pop(5))
‘Speed’
print(attributes)
[‘HP’, ‘Attack’, ‘Defense’, ‘Special Attack’, ‘Special Defence’]
attributes.insert(len(attributes), “Special skills”)
>>> attributes
[‘HP’, ‘Attack’, ‘Defense’, ‘Special Attack’, ‘Special Defence’, ‘Special skills’]
attributes[3] = “Magic”
attributes[4] = “Stamina”
print(attributes)
[‘HP’, ‘Attack’, ‘Defense’, ‘Magic’, ‘Stamina’, ‘Special skills’]
Ethan Li
Posted at 18:52h, 21 Augusta=[‘HP’,’Attack’, ‘Defense’,’Special Attack’,’Special Defense’,’Speed’]
a[4]:’Magic’
a[5]:’Stamina’
a. append(‘Special skills’)
del a[6]
a.insert(6, ‘Special Attack’)
a. insert(7, ‘Special Defense’)