PygLatin "check yourself" Why am I doing this?


#1

print 'Welcome to the Pig Latin Translator!'

raw_input("what's your name:")

original = raw_input()

if len(original) > 7:
print "original"

else:
print "empty"

INTERPRETER -

Welcome to the Pig Latin Translator!
what's your name: original
original
original
None

Why does the interpreter have me type "original" Twice.


#2

Because you are calling the raw_input() function twice. Assign the first call to your variable and remove the other line.


#3

like this??

print 'Welcome to the Pig Latin Translator!'

raw_input("original")

original = raw_input()

if len(original) > 0 and original.isalpha():
print "original"

else:
print "empty"


#4

I'm now on pop quiz of pyglatin..


#5

This is still two calls being made. Use,

original = raw_input("Enter a word to translate: ")

#6

print 'Welcome to the Pig Latin Translator!'

original = raw_input("what is my name:")

if len(original) > 0 and original.isalpha():
print "original"

else:
print "empty"

I have elimited the double typing in the translator. but i get this error now

Oops, try again. It looks like your code does not print original ("mahoney") when original is only made up of alphabetical characters


#7

The above is printing a string literal, as is this...

original is a variable, not a string literal so we never write it in quotes.

print original

#8

I have this now

print 'Welcome to the Pig Latin Translator!'

original = raw_input("what is my name:")
print original

if len(original) > 0 and original.isalpha():
print original

else:
print "empty"

I only had to type ONCE in the interpreter..


#9

it worked.. Does it look correct along the lines of code etiquette??


#10

Also, thank you guys very much..


#11

Learning etiquette includes being able to follow instructions and apply one's self to the problem without embellishing.

What is wrong with prompting for what the program expects? "what is my name" does not describe anything and has no bearing on the program. It is tomfoolery.

"Enter a word to translate:"

says what the program will be doing with the user input.

We are not asked to print original until after testing the user input.


#12

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