I'm brand new to Python, or programming in general and I'm working through the book "Python Crash Course". Right now I am learning about modules and the first thing I'm learning is about the import function.
I have two files. making_pizza.py and pizza.py
In pizza.py, I have the following
def make_pizza(size, *toppings):
"""Summarize the pizza we are about to make"""
print("\nMaking a " + str(size) +
"-inch pizza with the following toppings:")
for topping in toppings:
print("- " + topping)
Then in making_pizza.py I have the following.
import pizza
make_pizza(16, 'sausage')
I get the error "NameError: name 'make_pizza' is not defined" and import pizza is greyed out.
However, if I use
from pizza import make_pizza:
I can use the function.
Can someone explain why I am unable to use the "Import" function in Python? I'm using PyCharm as my interpreter.