0
What's is the problem , ans what's the solution ?
https://code.sololearn.com/cBS09PJ8Z7lZ/?ref=app Code from Extra-Terrestrials challenge The code takes only the last word of the input and i don't know why , please help
2 ответов
+ 1
Your code take only the last word because the values of "i" and "a" when you are going to works with is the last element of the list
To fix that you have to make some identations changes in your code and create new list to save in it each modified word
Your code will be like this:
a = input().split()
new_lst = [] #new
for i in a :
i = list(i)
a = i
print(a)
x = i[0]
a.pop(0)
a.append(x)
a.append("ay")
new_lst.append(a) #new
def str(i):
return ''.join(i)
#print each word using your str() function
for w in new_lst:
print(str(w), end=" ")
#end=" " to print all elements on a single line instead of printing each element on a single line
This is the answer of your question but this will not solve the extra-terrestrials challenge, if you need to solve it, you have to read it again and see how the input and the output will be(the solution is more simple than your written code)
0
Thanks so much 🙏🙏🙏