Problemi s Pythonom

Evo da ne otvaramo mnogo tema za mnogo problema kod ovog programskog jezika neka ovo bude tema sa pitanjima/problemima u Pythonu :slight_smile:

Pa evo da ja postavim prvo pitanjce, zasto mi ovaj kod javlja gresku :confused: (u online editoru prolazi, dok lokalno ne :confused: jako cudno)

Tekst zadatka :

Pig Latin is a language where we take the first letter of a word and put it on the end while also adding a vowel sound. So dog becomes “ogday”. What are the steps we need to take?[list=1]
[]Ask the user to input a word in English
[
]Check to make sure the user entered a valid word
[]Convert the word from English to Pig Latin
[
]Display the translation result
[/list]

Moje riješenje : (prolazi u online editoru)

original = raw_input('Enter a word:')
word = original.lower()
first = word[0]
j=len(original)
new_word=word + 'ay'
if len(original) > 0 and original.isalpha():
if first=='a' or first=='e' or first=='i' or first=='o' or first=='u':
print new_word
else:
new_word = word[1:j]+ word[0] + 'ay'
print new_word
else:
print 'empty'

Evo slika sa lokale : http://www.zaslike.com/files/uvji3354nzvegkx1cwc1.png

Pozdrav!

Koliko ja znam u py-u moze da postoji samo jedan if i jedan else. elif-ova mozes da imas koliko hoces…

To bi trebao da ti bude problem…

covece gde ja gresim :smiley: Hvala

original = raw_input(‘Enter a word:’)
word = original.lower()
first = word[0]
j=len(original)
new_word=word + ‘ay’
if len(original) > 0 and original.isalpha():
if first==‘a’ or first==‘e’ or first==‘i’ or first==‘o’ or first==‘u’:

print new_word
else:
new_word = word[1:j]+ word[0] + ‘ay’
print new_word
else:
print ‘empty’

Tu je greska. Mislim da je mislio da ne mozes da napises if nesto if to
Ovo je oblik

if len(original) > 0 and original.isalpha():
[b]else first==‘a’ or first==‘e’ or first==‘i’ or first==‘o’ or first==‘u’:

ili[/b]

if len(original) > 0 and original.isalpha():
elseif first==‘a’ or first==‘e’ or first==‘i’ or first==‘o’ or first==‘u’:
Ne koristim Python,ali probaj ovo.