Python Forum
IndentationError: unexpected indent
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndentationError: unexpected indent
#1


Hello Team,

I am currently taking a course on skillshare for Python. I am following along, but one example I keep get unexpected indent error.

This is the code I have:

in_stock = ["blue pens", "paper", "staples"]

shopping_cart = ["blue pens", "paper", "staples", "orange post-its"]

for item in shopping_cart:
    if item in_stock:
        print("Adding " + item + " to your order.")
    else:
        print("Sorry " + item + " is not in stock.")
I do not quite understand what the issue is as if and else are indented 4 spaces. print is indented a total of 8 spaces.

Anyone know what im doing wrong?
Reply


Messages In This Thread
IndentationError: unexpected indent - by belikewater - Oct-29-2017, 06:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help with "IndentationError: expected an indented block" hequ 3 6,563 Mar-02-2020, 06:26 AM
Last Post: Pranav
  IndentationError: expected an indented block python1980 3 7,793 Dec-03-2017, 10:00 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020