guys! So I recently started learning about python classes and objects. For instance, I have a following list of strings:
alist = ["Four", "Three", "Five", "One", "Two"]
Which is comparable to a class of Numbers I have:
class Numbers(object):
One=1
Two=2
Three=3
Four=4
Five=5
How could I convert alist into
alist = [4, 3, 5, 1, 2]
based on the class above?
My initial thought was to create a new (empty) list and use a for loop that adds the corresponding object value (e.g. Numbers.One) to the empty list as it goes through alist. But I'm unsure whether that'd be the most efficient solution.
Therefore, I was wondering if there was a simpler way of completing this task using Python Classes / Inheritance.
I hope someone can help me and explain to me what way would work better and why!
Thank you!!