fruit = 'banana' index = 0 while index < len(fruit): letter = fruit[index] print(letter, end='') index = index + 1I tried to reverse the string by changing 3rd line to
letter = fruit[-index]
, but it didn't work
print string in reverse
|
|
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 |