0
python logical error
It looks there are some logical errors in my code. How should I change my code in the case a word starts with a vowel and is capitalized or has punctuation? Also, I want you to help to write code how to concatenate a " " between words(main). Thank you in advance. Here is my code. https://code.sololearn.com/c9DuvrSt72xH
1 Odpowiedź
0
# this is my little version:
a = input().split()
b = ''.join(list(map(chr,range(97,123)))+list(map(chr,range(65,91))))
res = []
for i in a:
punc = i[-1] if i[-1] in '?!.' and len(i)!=1 else ''
if i[0] not in b:
res.append(i)
else:
if i[0] in 'aeiouy':
res.append(i[1:-1]+i[0]+'way'+punc)
else:
res.append(i[1:-1]+i[0]+'ay'+punc)
print('Translated: %s'%(' '.join(res)))