Running this code works in all circumstances except for not entering any input, line 9 throws an error (first = word) as it clearly doesn’t have a string to work with but how do I account for this if the error is occuring when stating variables before my function ?
Pig Latin Translator in Python
pyg = ‘ay’
Get a word from user and store in a variable
original = raw_input(‘Enter a word:’)
Make sure the input is lowercase
word = original.lower()
Store first letter of the input in its own variable
first = word
Create a variable concatenating the input, first letter and 'ay"
new_word = word + first + pyg
Store the rearranged input minus the first letter
new_word = new_word[1:]
Check the user has entered a valid word and print the pyglatin translation
if len(original) > 0 and original.isalpha():