Introdução
Minhas anotações sobre python
help('string')
retorna uma ajuda sobre o tipo string
source: http://aprenda-python.blogspot.com/2011/09/inverter-strings.html
Dada uma string, quero mostrá-la invertida. Em python é muito simples.
>>> 'eu gosto de python'[::-1]
'nohtyp ed otsog ue'
E se eu quiser inverter palavra por palavra, mas mantendo a ordem em que as palavras aparecem no texto?
>>> ' '.join([word[::-1] for word in 'eu gosto de python'.split()])
'ue otsog ed nohtyp'
Comments (0)
You don't have permission to comment on this page.