Pig Latin - Works on computer but not the website?


#1




It seem to work when I run in PyCharmCE but not on the website. ?? Different version of Python? I'm not sure what the problem is. Any ideas?


print("Pig Latin")
word=input("Please input a word \n " )
if len(word)==0:
    print ("This is not valid")
    word=input("Please input a valid word \n")
word=list(word)
word.append(word[0])
word.pop(0)
makeitastring=''.join(map(str, word))
print (makeitastring+"ay")


#2

input is not the same as raw_input(),

this should be word=raw_input("Please input a word \n " )


#3

I looked up what you said and from reading this I think I have Python 3 and my code academy is Python 2 maybe?

In Python 2, raw_input() returns a string, and input() tries to run the input as a Python expression. Since getting a string was almost always what you wanted, Python 3 does that with input() . As Sven says, if you ever want the old behaviour, eval(input()) works.Feb 6, 2011


#4

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