+ 1

How do I make a string spell backwards?

10th Aug 2020, 10:34 AM
Emmanuel Peter
Emmanuel Peter - avatar
6 Antworten
+ 3
it's very very simple!! def spell(text): #first store the text into a list List=list(text) #then reverse the list reverse_list=List[::-1] #now print the text elements vertically for i in range(len(reverse_list)): print(reverse_list[i]) text=input() spell(text)
6th Mar 2021, 11:23 AM
Bishwanath Kumar
Bishwanath Kumar - avatar
+ 2
def spell(txt): #obtain the size of txt sizeTxt = len(txt) #latest create a while with condition that sizeTxt != 0 while sizeTxt != 0: #print text vertically print(txt[sizeTxt-1]) #change the sizeTxt to avoid an infiniti loop sizeTxt -= 1 txt = input() spell(txt)
19th Mar 2021, 5:06 PM
Carlos Felipe Rivera Gueche
Carlos Felipe Rivera Gueche - avatar
+ 2
def spell(txt): #your code goes here if len(txt)==0: return else: print(txt[len(txt)-1:len(txt)]) txt=txt[0:len(txt)-1] spell(txt) txt = input() spell(txt)
13th May 2022, 4:00 PM
Harsha Sai Ganesh Pabolu
+ 1
I have the solution with recursive method: def spell(text, size): if size == (-1): return "" else: return text[size] + "\n" + spell(text, size-1) text = input() size = len(text)-1 print(spell(text, size))
1st Nov 2022, 12:33 AM
Carlos Felipe Rivera Gueche
Carlos Felipe Rivera Gueche - avatar
0
Letter Frequency
31st Oct 2022, 11:50 PM
Abdoukarim Sy
Abdoukarim Sy - avatar
- 1
how use recursion?
25th Mar 2021, 12:24 PM
TK PHAT
TK PHAT - avatar