+ 1
I am stuck help name = print(input("enter your name")) for letter "s" in name: return name + "e" print("good morning " , na
I want do built a program where when I input a name changes the last letter to an "s"
4 Réponses
+ 1
Nektarios P
simply u can use replace method
replace(oldstring,newstring)
in old string acess the last char in the string by len method
in newstring put "s"
and then print
+ 5
Nektarios P ,
can you show us your code (or what you have been trying so far) by linking it here?
thanks!
+ 5
Nektarios P ,
sorry to say, but there are too many issues in the code:
(i would suggest you to learn the basics of python from the "python for beginners" tutorial. then try it again)
(1. line) we should not print the input here. doing so, None will be stored in the variable name, since print() function returns None.
(2. line) incorrect for loop or should it mean an if conditional? the logic of getting the last letter of the string is missing. also the code is trying to add an
"e" to the variable name, but your description says that the last letter of the string should be changed to "s"
(3. line) return statement can only be used inside of functions
+ 1
name = print(input("enter your name"))
for letter "s" in name:
return name + "e"
print("good morning " , name)