The problem is from codeforces http://www.codeforces.com/problemset/problem/49/A

Just came back from Tesco, have shopped for the food next week. Feeling a bit tired, however, I enjoy solving small problems using Python. I think it will be a nice way to learn a new language. This problem is very easy and it is all about the implementation. Checking the last letter (using isalpha) if it is in the list of vowels.
The solution in Python is presented below. I got accepted just in 2 minutes, first try… hmmm.. energy now almost fully restored. 🙂
s = raw_input("")
i = len(s) - 1
v = ['A', 'E', 'I', 'O', 'U', 'Y']
while i >= 0:
if s[i].isalpha():
u = s[i].upper()
yes = 0
for vv in v:
if vv == u:
yes = 1
break
if yes:
print "YES"
else:
print "NO"
break
else:
i -= 1
Ok, in Python, you can check if an item is in some list by using the keyword in So the shorter implementation is below, which is also accepted without doubt.
s = raw_input("")
i = len(s) - 1
v = ['A', 'E', 'I', 'O', 'U', 'Y']
while i >= 0:
if s[i].isalpha():
u = s[i].upper()
if u in v:
print "YES"
else:
print "NO"
break
else:
i -= 1
–EOF (The Ultimate Computing & Technology Blog) —
270 wordsLast Post: Codeforces: A. Vasya and the Bus
Next Post: Codeforces: A. Super Agent