138. Fix the NameError in a Python Function
EasyScope
Overview
A variable made inside a function is local: return it to use it outside.
Problem Statement
The program in the editor should add up three prices and print the total with two decimals. Instead, it stops with:
NameError: name 'total' is not defined
Fix it so the function returns the total, and the main program stores and prints it. Keep the function cart_total(a, b, c).
The program uses input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One value per line: three prices, maybe with decimals. Example:
10
20.5
4.25
Output
The output for that example:
Total: 34.75
The tests try 3 different inputs.