I can't figure out why my script isn't working! Can someone please help!!! I'm doing this for my CS class. Here's the code:
feet1 = int(input('Enter the Feet: '))
inches1 = int(input('Enter the Inches: '))
feet2 = int(input('Enter the Feet: '))
inches2 = int(input('Enter the Inches: '))
feet_sum = (feet1 + feet2)
inches_sum = (inches1 + inches2)
def check(inches_sum, feet_sum):
while True:
if (inches_sum) > 12:
inches_sum -= 12
feet_sum += 1
return feet_sum
return inches_sum
break
check(inches_sum, feet_sum)
print('Feet: {} Inches: {}'.format(feet_sum, inches_sum))
UPDATE: Would this work? I'm pretty sure that it should take the variables and check to see if the inches are over 12 in a loop, and when the inches aren't over 12 it'll break the loop. Does that make sense?
feet1 = int(input('Enter the Feet: '))
inches1 = int(input('Enter the Inches: '))
feet2 = int(input('Enter the Feet: '))
inches2 = int(input('Enter the Inches: '))
feet_sum = (feet1 + feet2)
inches_sum = (inches1 + inches2)
def check(inches, feet):
while True:
if (inches_sum) > 12:
inches_sum -= 12
feet_sum += 1
else:
break
check(inches_sum, feet_sum)
print('Feet: {} Inches: {}'.format(feet_sum, inches_sum))
I think this is what you want:
feet1 = int(input('Enter the Feet: '))
inches1 = int(input('Enter the Inches: '))
feet2 = int(input('Enter the Feet: '))
inches2 = int(input('Enter the Inches: '))
feet_sum = (feet1 + feet2)
inches_sum = (inches1 + inches2)
def check(inches_sum, feet_sum):
while (inches_sum) >= 12:
inches_sum -= 12
feet_sum += 1
return inches_sum, feet_sum
inches_sum, feet_sum = check(inches_sum, feet_sum)
print('Feet: {} Inches: {}'.format(feet_sum, inches_sum))
Result:
Enter the Feet: 1
Enter the Inches: 26
Enter the Feet: 1
Enter the Inches: 26
Feet: 6 Inches: 4