0

Keep getting this error:

IndentationError: unindent does not match any outer indentation level

It is pointing at the end of this line:

relevantfolder = drive + ':\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\CADIQ_v' + version + '_si'

My code:

if test == criteria[2]:
   pass
   relevantfolder = drive + ':\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\CADIQ_v' + version + '_si'
      testsuccess = 0
      for file in os.listdir(relevantfolder):
         if file.startswith('CADIQ'):
            testsuccess = 1
            content += relevantfolder + os.sep + file + '\n'
      if not testsuccess:
         content += 'DID NOT FIND SHORTCUT ' + relevantfolder + '\n'
Red
  • 26,798
  • 7
  • 36
  • 58
  • As posted, the `pass` line and the `relevantfolder = ...` line are at exactly the same indentation level, so it's not clear what the problem is. Is the posted code accurate? – John Gordon Dec 11 '20 at 15:58
  • Does this answer your question? [IndentationError: unindent does not match any outer indentation level](https://stackoverflow.com/questions/492387/indentationerror-unindent-does-not-match-any-outer-indentation-level) – Zoe Dec 12 '20 at 23:34
  • @Zoe The situation here is different from the post you linked. – Red Dec 13 '20 at 02:11

1 Answers1

0

From

if test == criteria[2]:
   pass
   relevantfolder = drive + ':\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\CADIQ_v' + version + '_si'
      testsuccess = 0
      for file in os.listdir(relevantfolder):
         if file.startswith('CADIQ'):
            testsuccess = 1
            content += relevantfolder + os.sep + file + '\n'
      if not testsuccess:
         content += 'DID NOT FIND SHORTCUT ' + relevantfolder + '\n'

to

if test == criteria[2]:
    pass
relevantfolder = f'{drive}:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\CADIQ_v{version}_si'
testsuccess = 0
for file in os.listdir(relevantfolder):
    if file.startswith('CADIQ'):
        testsuccess = 1
        content += relevantfolder + os.sep + file + '\n'
if not testsuccess:
    content += 'DID NOT FIND SHORTCUT ' + relevantfolder + '\n'

Note that the pass doesn't do anything to the code.

Red
  • 26,798
  • 7
  • 36
  • 58