Python Forum
printing a string in reverse
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
printing a string in reverse
#1
i have a string in a variable x. i want to print that string in reverse order. like:
Output:
>>> x = 'foobar' >>> print(rev(x)) raboof >>>
... assuming rev() does the job for me. but if there is no rev()], what to code? i am not interested in answers without working code. i have tried reversed() and sorted(...,reverse=True) and have not yet found a nice compact solution.

if someone wants to implement rev(), try to make sure it will reverse the order of any sequence and return the very same type it was given..
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
printing a string in reverse - by Skaperen - Nov-20-2021, 12:35 AM
RE: printing a string in reverse - by bowlofred - Nov-20-2021, 12:54 AM
RE: printing a string in reverse - by ghoul - Nov-20-2021, 05:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Printing a raw string with a folder separator at the end, duplicates the separator krulah 5 1,219 Nov-28-2022, 12:41 PM
Last Post: snippsat
  printing an string instead of a expression Underscore 2 1,811 Oct-11-2021, 03:10 PM
Last Post: deanhystad
  I am trying to reverse a string using loop codinglearner 4 2,160 Sep-28-2021, 10:46 PM
Last Post: Pedroski55
  Printing string at specific position on terminal - not showing __Mathieu__ 1 2,372 Sep-07-2020, 10:32 AM
Last Post: Larz60+
  Reverse a String ragav_in 3 2,184 Jul-24-2020, 02:24 AM
Last Post: ragav_in
  Reverse the string word sneha 2 2,615 Dec-12-2019, 03:37 AM
Last Post: sneha
  printing a bytes string Skaperen 2 2,354 Jul-21-2019, 03:42 AM
Last Post: Skaperen
  String slicing in python from reverse ift38375 1 2,393 Apr-29-2019, 06:58 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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