Word Up


#1

pyg = 'ay'

original = raw_input('Enter a word:')

if len(original) > 0 and original.isalpha() :
    word = original.lower()
    first = word[0]
    print original
else:
    print 'empty'

I have also tried putting the word variable and first variable inside of the colon but that was not working either. It keeps saying did I define the variable word?


#2

what do you enter when you are prompted by raw_input? You need to enter a valid word


#3

ELEPHANT

I made it capital so that it would do the lower case function


#4

so i ran your code:

and it runs fine?


#5

mine still comes back and says the same thing


#6


#7

You have to create a variable, just after the variable "word" called "first" that contains the first letter of word.


#8

in the code you original posted you had first:

first = word[0]

why did you remove it?


#9

mine is still not working..

pyg = 'ay'

print 'Welcome to the Pig Latin Translator!'

Start coding here!

def restart():
original = raw_input("Enter a word:")
if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
print original
print word
else :
print "Please enter a valid word."
print "Please don't enter any non-alphabet characters."
restart()
restart()


#10

adding additional things (like a function), might cause problems, as it did in this case


#11

A post was split to a new topic: Word up


#12

A post was merged into an existing topic: Word up


#13

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.