Why is this not working?

The problem I am having is that when I run the code I type in the number 3 or 4 and it doesn’t let me enter the value of angle.

image

I get this error where the “Enter angle” prompt doesn’t appear.

Can someone help me, I am using IDLE python 3.11.2
If anyone needs further clarification pls tell me!

Here is whole code of my program

This is the error:

Would it were the code was pasted into a post (with formatting) so that we could run it ourselves and check for errors. May we ask you to post the raw code, please?

2 Likes

Here’s the code (formatted)

import math
# Import's the math libary
def geometry_calc():

    calculations = {"1) Circle_area": "r",
                    "2) Circle_circumference": "r",
                    "3) Circle_area_sector": "r, a",
                    "4) Arc_length": "r, a"}

    for keys, value in calculations.items():
        print(keys)
    # Makes it so that only the keys are printed out to console to show user what he can calculate

    type = str(input("""
Welcome to Abdullah's geometry calculator!
Type the number corresponding to the calculation you would like to calculate: """))

    if "r" in calculations.values():
    # Checking if the key only need a radius to be inputed
        radius = float(input("Enter radius: "))

        if type == "1":
            # circle_area
            print(math.pi * (radius) ** 2)

        elif type == "2":
            # circle_circumference
            print(2 * math.pi * radius)

    elif "r, a" in calculations.values():
    # Checking if the key needs a radius and angle to be inputed
        angle = float(input("Enter angle: "))
        radius = float(input("Enter radius: "))

        if type == "3":
            # circle_area_sector
            print((angle/360) * math.pi * (radius) ** 2)

        elif type == "4":
            # arc_length
            print((angle/360) * (2 * math.pi * radius))

    else:
        print("Error")
    
geometry_calc()

nvm, i found the problem