Python Forum
print string in reverse
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print string in reverse
#1
fruit = 'banana'
index = 0
while index < len(fruit):
    letter = fruit[index]
    print(letter, end='')
    index = index + 1
I tried to reverse the string by changing 3rd line to letter = fruit[-index], but it didn't work Snooty
Reply


Messages In This Thread
print string in reverse - by pseudo - Oct-02-2018, 11:26 PM
RE: print string in reverse - by wavic - Oct-02-2018, 11:49 PM
RE: print string in reverse - by pseudo - Oct-03-2018, 12:42 AM
RE: print string in reverse - by gruntfutuk - Oct-04-2018, 04:23 PM
RE: print string in reverse - by pseudo - Oct-04-2018, 06:55 PM
RE: print string in reverse - by buran - Oct-04-2018, 08:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading a text until matched string and print it as a single line cananb 1 2,083 Nov-29-2020, 01:38 PM
Last Post: DPaul
  How to print the docstring(documentation string) of the input function ? Kishore_Bill 1 3,621 Feb-27-2020, 09:22 AM
Last Post: buran
  Reverse string sentence with for loop? BillGates 3 6,198 May-02-2017, 04:15 PM
Last Post: wavic
  Print the index of the vowels in a string MeeranRizvi 4 14,808 Dec-29-2016, 02:43 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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