I am doing Python Hoemwork 2 Store items Why my code shows identation errors? File "", line 7 item1 = input("Enter item 1's name >>") ^ IndentationError: unindent does not match any outer indentation level Here is my current code : # Hard-Coded variable representing the store store = "Welcome to the Store" # print the value of the variable print(store) # two variables which represent the items to be purchased and input from the user item1 = input("Enter item 1's name >>") item2 = input("Enter item 2's name >>") # print the items print("Items are: {orange}, {strawberry}".format(item1, item2)) # two variables for the cost of each item to be purchased cost1 = float(input("Enter cost of item 1: 25")) cost2 = float(input("Enter cost of item 2: 20")) # print the cost with the items print("Item 1 - {} with Cost = {}\nItem 2 - {} with Cost = {}".format(item1, cost1, item2, cost2)) # two variables for computing the subtotal and taxamount for the user # tax amount is 10% of the cost of the items subtotal = cost1 + cost2 taxAmt = subtotal*0.1 # output the subtotal and tax amount print("SubTotal - {}\nTax Amount - {}".format(subtotal, taxAmt))
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
I am doing Python Hoemwork 2 Store items Why my code shows identation errors?
File "<tokenize>", line 7 item1 = input("Enter item 1's name >>") ^ IndentationError: unindent does not match any outer indentation level
Here is my current code :


We need to rectify the errors in the given Python code.
There are 2 problems with the code:
1. Indentation is not proper.
2. In line 9, "print("Items are: {orange}, {strawberry}".format(item1, item2))" is wrong. It should be "print("Items are: {0}, {1}".format(item1, item2))".
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images









