Well, here is my code:

print "Welcome to the English to Pig Latin translator!"
original = raw_input("Please enter a word: ")
pyg = "ay"
if len(original) >= 1 and original.isalpha()
    word = original.lower()
    first = word[0]
        if word == a or e or i or o or u
        print "Your first letter is a vowel"
        else print "You'r first letter is a consonant"
        print
    print "So your word is " + original
else:
    print "No word detected."

As you can see there are no colons, even thought there should be. It is not a finished program yet and I am doing it for this site called http://codecademy.com I need help understanding colons in python...

Recommended Answers

Colons(:) are basic and important in python.
Other languages use { } or other method to indicate/use a code block.
Python use indentation after colons(:) to indicate/use a code block.

word = 'hi'
if word == 'hi':
    print'Now this block get executed an word is …
Jump to Post

All 3 Replies

Colons(:) are basic and important in python.
Other languages use { } or other method to indicate/use a code block.
Python use indentation after colons(:) to indicate/use a code block.

word = 'hi'
if word == 'hi':
    print'Now this block get executed an word is equal to hi'
else:
    print'Now this block get executed an word is not equal to hi'

So it look like this.

print "Welcome to the English to Pig Latin translator!"
original = raw_input("Please enter a word: ")
pyg = "ay"
if len(original) >= 1 and original.isalpha():
    word = original.lower()
    first = word[0]
    #if word == a or e or i or o or u:
    if first in 'aeiou':
        print "Your first letter is a vowel"
    else:
        print "You'r first letter is a consonant"
        print "So your word is {}".format(original)
else:
    print "No word detected."
commented: nice help +13

Every time group of statements follows, that line ends in colon and the block is indented.

Thanks for the explanation snippsat. Also thanks for correcting that line of code with the vowels, I shoulda known it couldn't have been that easy...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.