+ 1

Extra-terrestrials

#task: take a word as input, and output it backwards word=input() #makes a variable word=list(word) #converts word to a list drow=word.reverse() #makes another variable print(str(drow)) #converts drow to a string #unfortunately, it outputs None all the time. what’s wrong?

28th Sep 2023, 11:15 PM
Annihilate
Annihilate - avatar
8 Respostas
+ 3
Trey , here some hints how the exercise can be done: https://code.sololearn.com/cB69K21tN6kd/?ref=app
29th Sep 2023, 6:59 PM
Lothar
Lothar - avatar
+ 6
.reverse() doesn't return anything. it updates what you call it on in place. so if you set it equal to a variable, as you have done with "drow" it will assign "None" to that variable
29th Sep 2023, 1:12 AM
Aaron Lee
Aaron Lee - avatar
+ 1
Thanks, Lothar
30th Sep 2023, 12:17 AM
Annihilate
Annihilate - avatar
0
Hmm, maybe that’s the case. So do I use the variable “word” throughout or something else?
29th Sep 2023, 8:25 PM
Annihilate
Annihilate - avatar
0
If you want to keep your naming scheme, you could just replace the line: drow = word.reverse() with: word.reverse() drow = word
29th Sep 2023, 10:03 PM
Aaron Lee
Aaron Lee - avatar
0
Okay, now what?
29th Sep 2023, 10:58 PM
Annihilate
Annihilate - avatar
0
What is the goal of your code? take a look at Lothar's Code
29th Sep 2023, 11:03 PM
Aaron Lee
Aaron Lee - avatar
0
New Game , I saw this late by reading your profile. I solved that Code Coach without variables using a slice. print(input()[::-1])
4th Jan 2024, 7:17 AM
Rain
Rain - avatar