Question: import locale File / Users / daniellewhite / Desktop / Python / locale . py , line 5 , in locale.setlocale ( locale

import locale
File "/Users/daniellewhite/Desktop/Python/locale.py", line 5, in
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
NameError: name 'locale' is not defined. Did you mean: 'locals'? Or did you forget to import 'locale'?
i keep getting this error no matter what i do. here is the code I have
import locale
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
prices =[]
while True:
price = float(input("Enter a price: "))
if price <0:
print("Price cannot be negative. Please re-enter.")
continue
prices.append(price)
for p in prices:
print(locale.currency(p))
subtotal = sum(prices)
tax = subtotal *0.1
total = subtotal + tax
print("
Subtotal:", locale.currency(subtotal))
print("Tax:", locale.currency(tax))
print("Total:", locale.currency(total))
choice = input("Do you want to enter another price? (yes/no): ")
if choice.lower()!= "yes":
break
i have locale as
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!