I am stuck help name = print(input("enter your name")) for letter "s" in name: return name + "e" print("good morning " , na | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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"

28th Jun 2022, 3:57 AM
Nektarios P
Nektarios P - avatar
4 Answers
+ 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
28th Jun 2022, 4:19 AM
Aly Alsayed
Aly Alsayed - avatar
+ 5
Nektarios P , can you show us your code (or what you have been trying so far) by linking it here? thanks!
28th Jun 2022, 11:09 AM
Lothar
Lothar - avatar
+ 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
28th Jun 2022, 2:52 PM
Lothar
Lothar - avatar
+ 1
name = print(input("enter your name")) for letter "s" in name: return name + "e" print("good morning " , name)
28th Jun 2022, 12:50 PM
Nektarios P
Nektarios P - avatar