Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reversing a string
#4
I like nilamo solution.

One possible way without itertools:
user_input = 'Hello World'
text = ' '.join(user_input.split()[::-1])
tmp = ''
for char in text:
    tmp = ''.join((tmp, char))
    print(tmp)
 
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
reversing a string - by kerzol81 - Jul-18-2018, 02:32 PM
RE: reversing a string - by ichabod801 - Jul-18-2018, 05:21 PM
RE: reversing a string - by nilamo - Jul-18-2018, 06:34 PM
RE: reversing a string - by perfringo - Jul-18-2018, 09:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  reversing strings westbob 4 2,625 Jun-11-2019, 04:11 PM
Last Post: buran
  Reversing a String grkiran2011 1 2,358 Dec-02-2017, 04:43 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020