PygLatin and other


#1

Why this code does everything only 3 times and after I need to start it again. If somebody can point me
how can I make it work unlimited time until I want to stop it? Thank's

#word = 'hey'
def stage():
    original = input  ('Enter a word:')
    if len(original) > 0 and original.isalpha():
        '''first = (original.lower())
        second = (first[0])
        third = first + second + word'''
        print (original)
    else:
        print ('Sorry, You can use only letters!')

stage();

def only():
    if stage() != True:
            return (stage())
only();

#2

You are close but a little off on how to implement something like this.

Your best bet is to use a while loop and with a nested try/except/finally statement that catches keyboard breaks and the such. You can also add code to ask after each iteration if the user would like to stop.

Python Example:

while True:
    try:
        x = 0
        print(x)
        x += 1
        ask = input"Would you like to quit? Y/N")
        if ask[0].lower() == 'y':
            break
    except KeyboardInterrupt:
        break

Something like this would work for you, it is generally called a mainloop of your program. Always ensure you have some way to break your code or stop it or it will run forever.