6
Hail!
I’ve been looking for elegant ways to do string inversion, arrays and integers in Python.
What do you think of my codes below and what suggest to improve them? They work...
Thank you!
frase = 'eu gosto de python'[::-1]
numero = [12, 13, 14, 15, 16, 17]
inteiro = 123456
numeroInvertido = int(str(inteiro)[::-1])
print frase
print numero [::-1]
print numeroInvertido
Hello, welcome to [en.so]! The solutions seem reasonable to me - although I’m not a Python expert. But perhaps it would be good to explain what exactly you intend to do with the inverted values. For example, if the idea is just to iterate once over a reversed list it might not be very efficient to duplicate the list in memory.
– utluiz