We've created a lot of classes in this course, now let's write some code that uses them. Let's have ourselves a little dragon fight.
Complete the bottom half of the main() function using two for-loops:
Pass in the dragons in the same order as the original list, excluding the current dragon. For example, when Blue Dragon breathes fire, it should check to breathe fire on the other dragons in this order:
When you describe the dragons, your output should look like this:
Green Dragon is at 0/0
Red Dragon is at 2/2
Blue Dragon is at 4/3
Black Dragon is at 5/-1
The output of the first dragon breathing fire should look like this:
====================================
Green Dragon breathes fire at 3/3 with range 1
------------------------------------
Red Dragon is hit by the fire
Blue Dragon is hit by the fire
====================================
Red Dragon breathes fire at 3/3 with range 2
------------------------------------
To get a new copy of a list, use the copy() method. If you just do new_list = old_list, your new variable will just be a reference to the original list... which is not what we want.
nums = [4, 3, 2, 1]
nums_copy = nums.copy()
# nums_copy is [4, 3, 2, 1]
fruits = ["apple", "banana", "cherry", "kiwi"]
del fruits[1]
# fruits is ["apple", "cherry", "kiwi"]