So here is my entire code, I am having trouble when it says height is not defined in window_Calculate()
. My aim is to use the formula 50 + (height * width) * 100
. In window_Size
, the user must input a height
and width
but if they type anything that is not a number, it is supposed to return it so they can enter in an actual number. Overall, height
is not defined while in a different function and does not return back to the input if user enters anything but numbers. How can I make height
defined and return back to the input?
import time
def Intro():
print("Welcome to Wendy's Windows.")
time.sleep(2)
print("This is a window replacement business.")
time.sleep(2)
print("Enter your size in the box on the left and the price will be displayed below.")
time.sleep(2.5)
def window_Size():
print("Put height first then put width.")
time.sleep(1.5)
height = input("Height: ")
try:
int(height)
except ValueError:
try:
float(height)
except ValueError:
print("Enter only numbers.")
return(height)
else:
print(height + "m")
width = input("Width: ")
try:
int(width)
except ValueError:
try:
float(width)
except ValueError:
print("Enter only numbers.")
return(width)
else:
print(width + "m")
def window_Calculate():
window_Calculate = '50' + (height * width) * '100'
def window_Cost():
print("Your price is" + window_Calculate + "$")
window_Size()
window_Calculate()
window_Cost()