Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 13
"backwards" is spelled
b a c k w a r d s
where is the problem? 🙄
+ 11
Wayne ,
there are various ways of doing this task. one of them could be recursion.
before we are going to help you, please present your attempt here. if you haven't done a try by yourself so far, please do so. create your code in playground and post the link to it here.
please also provide a proper task description with sample of input and output.
thanks!
+ 3
To reverse a string you mean? You can do this
string = 'hey'
string = string[::-1]
print(string)
Output: yeh
And if you want to separate each letter of the word (i think is what you mean of spell) you can do this:
def separate (word):
return [char for char in word]
string = separate(string)
output: [‘y’, ‘e’, ‘h’]
+ 2
Hi Wayne!
Using for loop is your another choice. You can make a 2/3 lines code with the help of some in-built functions like, range() and len()
+ 2
Wayne Spell backwards what? If it's a text, then slicing it might help:
text[::-1]
+ 2
print(("Hello World!")[::-1])
+ 1
Wayne Your question appears to a duplicate please use the searchbar before asking.
Please use the forum guidelines provided below and use the 8 rules for getting help from the community.
https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community
Your question will be marked for deletion.
Reason duplicate threads are removed to:
Focus substantially similar discussion in one thread and to prevent forums being cluttered with multiple threads on the same topic.
https://www.sololearn.com/Discuss/1316935/?ref=app
https://www.sololearn.com/discuss/1613864/?ref=app
https://www.sololearn.com/discuss/2280068/?ref=app
https://www.sololearn.com/discuss/1362802/?ref=app
https://www.sololearn.com/discuss/2638450/?ref=app
https://www.sololearn.com/discuss/1525821/?ref=app
https://www.sololearn.com/discuss/1748913/?ref=app
https://www.sololearn.com/discuss/2219532/?ref=app
https://www.sololearn.com/discuss/1485001/?ref=app
0
Can u also use recursion or is it only with recursion
0
You can use recursion
- 3
By using slicing