Testing, Testing, is This Thing On? Pygin


#1



https://www.codecademy.com/courses/python-beginner-2W5v7/1/5?curriculum_id=4f89dab3d788890003000096


File "python", line 6
new_word = [1:len(original)] + first + pyg
^
SyntaxError: invalid syntax


pyg = 'ay'
print "Welcome to Pygin game"

original = raw_input('Enter a word:')
word = original.lower()
first = word[0]    
new_word = [1:len(original)] + first + pyg
    
if len(original) > 0 and original.isalpha():
    print original
else:
    print 'empty'


#2

Guys.. I got the solution.. It's shown below

pyg = 'ay'
print "Welcome to Pygin game"

original = raw_input('Enter a word:')

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


#3

This code too will do the magic!

pyg = 'ay'

original = raw_input('Enter a word:')

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


#4

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