Search code examples
pythonkeraslstm

else = invalid syntax.. What to change?


if random_numbers == predicted_numbers: seed_found=True # body of if statement
predicted_seed=seed 
else: 
attempts += 1

error says "Cell In[48], line 16 else: ^ SyntaxError: invalid syntax"

I want the error "invalid syntax" for 'else' to go away

[I still made a mistake][1] [1]: https://i.sstatic.net/DRCi5.png


Solution

  • Maybe the identation of your code is the problem Try this:

    if random_numbers == predicted_numbers: 
      seed_found=True # body of if statement
      predicted_seed=seed 
    else: 
      attempts += 1