Well, your syntax is wrong:
- Indentation matters.
- The backslashes at the ends of each line mess with your indentation and with ending your statements. They need to go away.
- Don't end statements with
;
, this is Python, not C. Statements end with a newline (which, again, is escaped by your backslash).
Then,
i = i++;
doesn't make much sense in any language, but Python doesn't even have a ++
operator, and Python doesn't need/use semicolons to end a statement.
You want
i += 1
Also, don't use str
as a variable name, you're shadowing the built-in type that way.
Furthermore, you never want to use a bare except:
- always catch specific exceptions.
Finally, do you really want to compare against None
? If so, use
hdulist[0].header[30] is None # None is a singleton!
But all in all, it looks very much like you should be reading a basic Python tutorial before venturing any further.