2

When running this piece of code:

#timestamp, capture, and tweet an image
def stamp_cap_tweet():    
    timestamp = time.strftime("%d%m%Y-%H%M%S")
    os.system("fswebcam -r 960x720 -d /dev/video0 " + timestamp + ".jpg") #save image to disk
    twit.update_status_with_media(timestamp + ".jpg", status = "@shahidrogers " + timestamp) #tweet image @username
    print "Tweeted image at " + timestamp #make a record in the Python output

I get the error

File "tweetpicture.py", line 17

os.system("fswebcam -r 960x720 -d /dev/video0 " + timestamp + ".jpg")                                                  
                                                                    ^                                                   IndentationError:

unindent does not match any outer indentation level

What could this possibly mean? I have searched around and people have said that there's a mix of tab and spaces, but I do not understand this at all as I am still very new to Python and this is my first few lines of coding.

Thanks!

Shahid Rogers
  • 69
  • 1
  • 1
  • 5

1 Answers1

6

In Python code each level of indentation must contain exactly the same sequence of spaces and tabs for each line that is indented to at least that level.

The best and most simple way to achieve this is to only use spaces, always in the same number, for each indentation level. The suggested number is four.

Many editors can be configured to replace tabs with a given number of spaces.

Nicola Musatti
  • 17,834
  • 2
  • 46
  • 55