Nov-06-2016, 10:20 AM
(Nov-05-2016, 09:17 PM)SrirachaSauceLover Wrote:(Nov-05-2016, 08:39 PM)Barrowman Wrote: SrirachaSauceLover
All you do is delete the spaces in front of the text. In your code you had
main()
which has 8 spaces in front of it. Just delete them
I do this and am greeted with:
SyntaxError: unindent does not match any outer indentation level
Okay so it seems you have some problem with making sure that everything is aligned as it should be so let's see if you can get it right.
>>>> Looking at the version I posted <<<< Just to remove any confusion.
When you create the function with def main():
it should start on a line with no spaces to the left of it.
The next line
inp = raw_input("Enter a value between 0 and 1: ")
should have 4 spaces to the left of it.
After that x = float(inp)
and
for i in range(10):
should each have 4 spaces in front of them.
Then
x = 3.9 * x * (1 - x)
and
print x
should have 8 spaces in front of them
Finally
main()
should have no spaces in front of it.
If you get all that right you will not get the error.
The interpreter needs this consistent format so it knows where the def ends and where the for loop ends.
Note that if the def is itself within another def such as
class example():
the def needs to have 4 spaces to the left of it and all the other bits need an extra 4 spaces to the left of them.
I have said 4 spaces and then 8 spaces because that is the standard way and a good habit to get into. You could use 3 and 15 or 7 and 11 and so on but whatever you use it has to be consistent or you will get the unindent error.
Often copy and paste can cause this error.