- 1
Why it doesnt work:
tried pig latin in python (i know that last is wrong, but it still doesnt do what it should) def take(inp): inp = list(inp) last = len(inp) - 1 first = 0 inp[last] = inp[first] inp.remove(inp[first]) inp.append('ay') inp = "".join(inp) return inp xl = list(input()) last = len(xl) - 1 y = 0 start = 0 word = 0 words = [] i = 0 while y <= last: if xl[y] == ' ' or xl[y] == last: word = xl[start:y-1] words.append(take(word)) words.append(' ') start = y + 1 y += 1 words = "".join(words) print(words)
3 odpowiedzi
0
nihil join in take func. works, idk why you think it doesnt xl[y] == last is my mistake, thanks for pointing it out and i dont understand what is hard to understand in this code its very basic, but i just started writing in python like a day ago, before that I was writting in c++ only
thanks for a way to split a sentence, couldnt find it anywhere
0
i will try to fix the code now. again thanks for the way to split a sentence
0
fixed it. added a few things. thanks for help nihil. i know its not perfect
def take(inp, num):
inp = list(inp)
last = len(inp) - 1
first = 0
inp.append(inp[first])
inp.remove(inp[first])
if num == 1:
inp.append('ay ')
else:
inp.append('ay')
inp = "".join(inp)
return inp
words = []
y = 0
x = input().split(' ')
while y < len(x):
if y == len(x) - 1:
words.append(take(x[y], 0))
else:
words.append(take(x[y], 1))
y += 1
words = "".join(words)
print(words)