Awesome, thanks. I had known of enumerate, but completely forgot. I actually looked around to see if there was a built-in or library for number names, just to simplify things.
AttributeError: 'list' object has no attribute 'update'
Is that something from a newer version than I have? I can't search for it. Every attempt through Google takes me to the use of the word 'update' for other reasons.
Comments 5
zip(range(len(num)), num) can be written as enumerate(num)
and
for i in [(0, 'zero'), (10, 'ten'), (11, 'eleven'), (12, 'twelve'), (13, 'thirteen'), (15, 'fifteen'), (18, 'eighteen')]: num[i[0]] = i[1]
can be written as
num.update({0: 'zero', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 15: 'fifteen', 18: 'eighteen'})
The append() call with all the ternaries doesn't feel right it python. You'd usually just see it as a if: elif: else: block.
Reply
Reply
AttributeError: 'list' object has no attribute 'update'
Is that something from a newer version than I have? I can't search for it. Every attempt through Google takes me to the use of the word 'update' for other reasons.
Reply
Reply
Leave a comment