Pyglatin 4. Check yourself - how to write print?

print ‘Welcome to the Pig Latin Translator!’

Start coding here!

original = raw_input (“Enter a word:”)

empty_string = “”
if len(empty_string) > 0 :
print original
else:
print “empty”

original = raw_input(“Enter a word:”)
if len(original) > 0:
print original
else:
print “empty”

This is what I did and it worked.

1 Like

@bitrockstar43061

It does say to define original = raw_input("Enter a word:") and then see if that is empty or not.

As @gpvlr45 has in his code.

I don’t understand why I have to put de () in print (original)

print ‘Welcome to the Pig Latin Translator!’

original = raw_input(“Enter a word:”)
if len(original) > 0:
print (original)
else:
print “empty”

1 Like

I tried that exactly and it didn’t work. it said “invalid syntax, line 5”

did you write everything in one line? If you did, you need to write each in separate line like how I did in my post.

This worked for me:

print 'Welcome to the Pig Latin Translator!'

original = raw_input("Enter a word:")
empty_string = ""
if len(original) > 0:
    print original
else: 
    print "empty"
2 Likes

But then your line with
empty_string = ""
has no use at all?

becasue original is a variable, that has an assigned value, print(variable) <—this really means: print (word that user typed). and the word that user typed was stored as a variable named original, sooo Print(original) works :smiley: i hope this helps i tried to explain that the best i could :smiley:

“welcome to the pig latin translator!” is a string. strings on the other hand, (from what i understand) are pretty much straight forward. they arent assigned and special value or variable.

@js_ thank you, for putting that out there, it really helped me pass the level! :)smile:

my code was also the same but it gave always same problem
then i tried

original = raw_input(“Enter a word:”)
if len(original) > 0:
print original
else:
print “empty”
this way, pay attention on SPACE and than it worked.

viel spass

print “Pig Latin”

original = raw_input(“Enter a word:”)
empty_string = “”
if len(original) > 0:
print original
else:
print “empty”

Thank you this was very helpful!

My code says:
Oops, try again. Oops! Did you accidentally delete the variable called original? but it is all there!

print ‘Welcome to the Pig Latin Translator!’

original = raw_input(“What is your name?:”)
if len(original) > 0:
print original
else
print “Empty”

I did the below. Is this right? Especially the part in bold.

print ‘Welcome to the Pig Latin Translator!’

Start coding here!

raw_input(“Enter a word:”)
original = raw_input()
if len(original) > 0:
print original
else:
print “empty”

hey @medouxa

when i do that it says invalid syntax line 12,which is the line that says:

else:

@micac

please help me if you can with my question above

I had with the same problem because I used the space incorrectly in ‘else’. Your reply helped me so much. :slight_smile:

i have tried all of the above and nothing is working. I am also getting an( Oops try again! Did you create a variable called original?) error. Is anyone available to help?

I’ve somehow figured it out, thanks.