Quote:What is a more Pythonic way of doing this? I've seen some examples using tuples and dictionaries
It would be something along the lines of.
d = { 1:1, 2:10, 3:100, 4:1000, 5:10000 } if integerLength in d: n = d[integerLength] else: n = 100000Or if you wanted the else clause in the dict
d = { 0:100000, 1:1, 2:10, 3:100, 4:1000, 5:10000 } if intergerLength in d: n = d[interLength] else: n = d[0]dont quote me on that though, i literally just woke up and it takes a few for my brain to start
![Think Think](https://python-forum.io/images/smilies/eusa_think.gif)
Recommended Tutorials: