Question: Sorry if not too clear, creating a program to calculate a formula and using cataloged values for one variable which are stored in a nested dictionary. I want to have the user be able to pull values from the dict like so:

```
def get_value():
x = input("Material: ")
if x in materials:
    y = input("Gauge: ")
    if y in x:
        return materials[x][y]
    elif not (not (y is None) and not (y not in x)):
        return 0
elif x not in materials or x is None:
    return "Invalid Punch"

```

is there any specific way to do this that I'm messing up? Every time I try to run it I get a Nonetype, which I have set to replace with a default value of 0.
Dict for reference

```
materials = {"ss": {22: "", 21: "", 20: "0.431", 19: "", 18: ""
        ,17: "", 16: "", 15: "", 14: ""
        ,13: "", 12: "", 11: "", 10: "", 9: "", 8: ""}, }

```

Answer: 
Change your line: `if y in x:` to `if y in materials[x]:` you need to check if `y` is in the dict of `x`. `y in x` checks if `y` is part of `x`
You should use [raw\_input()](https://docs.python.org/2/library/functions.html#raw_input) instead of [input()](https://docs.python.org/2/library/functions.html#input).

`input()` will evaluate the input as python code, whereas `raw_input()` will return a string.

Also, as @DanielMesejo mentioned in their answer the condition `y in x` won't work as both will be strings. You should check `y in materials[x]`.

```
def get_value():
    x = raw_input("Material: ")
    if x in materials:
        y = int(raw_input("Gauge: "))
        if y in materials[x]:
            return materials[x][y]
        elif not (not (y is None) and not (y not in materials[x])):
            return 0
    elif x not in materials or x is None:
        return "Invalid Punch"

print(get_value())

```

Output:

```
0

```

This doesn't work because the gauge index is an int, not a string. `raw_input` return a string! So we need to type cast it:

```
def get_value():
    x = raw_input("Material: ")
    if x in materials:
        y = int(raw_input("Gauge: "))  # Converting raw_input response to int
        if y in materials[x]:
            return materials[x][y]
        elif not (not (y is None) and not (y not in materials[x])):
            return 0
    elif x not in materials or x is None:
        return "Invalid Punch"

print(get_value())

```

Output:

```
0.431

```

Your expression on line #7 is more complicated than is necessary so I have made a simpler function for you:

```
def get_value():
    material = raw_input("Material: ")
    if not material or material not in materials:
        return "Invalid Punch"
    gauge = int(raw_input("Gauge: "))
    if not gauge or gauge not in materials[material]:
        return 0
    return materials[material][gauge]

```

Usage:

```
> python input.py
Material: ss
Gauge: 20
0.431

```