Python, check yourself


#1

Hi, new in this and got stuck here. The program gives you this code, and you are suppose to write something. the problem is that when I press run, the word empty always gets printed. Any ideas, please? thanks in advance for your help.

print ‘Welcome to the Pig Latin Translator!’

Start coding here!

original = raw_input("Enter a word: ")
print original
empty_string = “”
if len(empty_string)> 0:
#run this block
print original
else:
#that string must have been empty
print “empty”


#2

why is there an empty_string variable?


#3

Honestly, no idea. It wa salready there, and cannot figure out what I am suppossed to write in there :sweat: #learningtypingbeingadummy


#4

Ok, I changed the code for this, and I think it works… Does this make sense?

print ‘Welcome to the Pig Latin Translator!’

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


#5

but why did you make these changes? What do you think made this work?


#6

I thought it made no sense to have an empty variable. Also, the variable I wanted to check if was empty was “original”, so kind of made sense to measure the length of original instead of creating a new variable…


#7

yep, exactly :slight_smile:


#8

thanks so much!! :hugs:


#9

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