How can i make my Pig latin better?
I always see someone got a better version of this but i really want to know how can i improve my version of Pig Latin https://code.sololearn.com/cE2NSXokX3iT/?ref=app
Style: - start your variable names with lowercase - but do not use reserved / built-in names such as list / List Code: - avoid mutating the loop variable (x) - do not change it inside the loop - learn and use list comprehensions, and map, filter functions One liner: print(' '.join(map(lambda w: w[1:]+w+'ay', input().split())))
Using list comprehension [print("".join(i[1:]+i+"ay"),end=" ") for i in input().split()]
# Here’s a simple one: print(*(s[1:] + s + "ay" for s in input().split()))
#shortened your code, there can be more better ways. lst = input().split() sentence="" for x in lst : sentence += x[1:]+x+"ay " print(sentence)