0

Need help with this problem.

I am trying to take first letter of each word and put it at the end of the same word . I think i am close but some thing is off i dont know where . This is my code : a = 'arm am max' b = list (a.split (' ')) c = "" for j in b : list = list (j) first = list.pop (0) list.append (first) string = str ( list ) c += string print (string )

28th Aug 2020, 11:36 AM
Max Lwe
Max Lwe - avatar
10 Antworten
+ 3
1. The split function already returns a list, so no need of adding that 'list()' 2. Don't use the name 'list' as it is already a function! Use another variable name like 'l' or 'lst' 3. Don't use the str tag with lists, str([1,2,3]) => [1,2,3] and here the second element is not 2 but it is 1 and similarly the third element is , So instead use print ("".join(['1','2','3'])) which will give => 123 4. At the last you should print c and not string. With every loop add a space " " to the variable c 5. I really liked your approach with pop function!👍🙌 keep it up! Here's a one liner solution for pig latin https://code.sololearn.com/cy5AZdpsxNvn/?ref=app
28th Aug 2020, 12:12 PM
Namit Jain
Namit Jain - avatar
+ 2
Max Lwe to whom?
28th Aug 2020, 12:22 PM
Namit Jain
Namit Jain - avatar
+ 1
no need for too much line of code! a="I can do it all day" b=''.join(i[1:]+i[:1]+" " for i in a.split(" "))
28th Aug 2020, 11:44 AM
Shadoff
Shadoff - avatar
+ 1
You sure? Koay hentay. appyhay odingcay!
28th Aug 2020, 11:56 AM
Shadoff
Shadoff - avatar
+ 1
😁 this is not indian! This Is Spart... Khm... This is pig latin. You know what I mean bro? Hint: Code coach
28th Aug 2020, 11:59 AM
Shadoff
Shadoff - avatar
+ 1
Happy coding 😅😅
28th Aug 2020, 12:00 PM
Max Lwe
Max Lwe - avatar
0
Can you please explain ur code . It will make my day.
28th Aug 2020, 11:47 AM
Max Lwe
Max Lwe - avatar
0
Nevermind i got it thanks for your help.
28th Aug 2020, 11:53 AM
Max Lwe
Max Lwe - avatar
0
I am not Iindian bro
28th Aug 2020, 11:57 AM
Max Lwe
Max Lwe - avatar
0
Thanks
28th Aug 2020, 12:16 PM
Max Lwe
Max Lwe - avatar