I am currently in need of help on a piece of homework, I'm using python 3.3 and i need to set a delay on a times table program that i created heres the code:

def get_int(prompt="Enter an integer: "):
    """this function will loop until an integer is entered"""
    while True:
        try:
            # return breaks out of the endless while loop
            return int(input(prompt))
        except ValueError:
            print("Try again, value entered was not an integer.")
x = get_int ("Enter a number: ")
for i in range(1,13):
   print (x*i)

Is it possible to add a delay without changing the code dramatically or would i have to change everything? Thanks in advance.

You mean something like this ...

import time

def get_int(prompt="Enter an integer: "):
    """this function will loop until an integer is entered"""
    while True:
        try:
            # return breaks out of the endless while loop
            return int(input(prompt))
        except ValueError:
            print("Try again, value entered was not an integer.")

x = get_int ("Enter a number: ")
for i in range(1,13):
   print(x*i)
   time.sleep(1.2)
This question has already been answered. Start a new discussion instead.