invalid syntax points to "return" in python -


i exploring vast language of python. i'm heavily relying on inbuilt error-decetion , googling debug programs. had no luck time around. thank time!

i getting

"invalid syntax @ line 5"

here python-code of simple hangman-game:

import random  def __secretword__():     secret_word = word_list[random.randomint(len(word_list))     return secret_word #this line 5  def __ask__():     ans = input("would play more? (yes/no): ")     if ans == "yes"         __secretword__()     else:         print(":(")   __secretword__()  word_list = ["nei", "brun", "ja", "smile", "glad", "gal"] secret_word = secret_word sw_list = list(secret_word) guess_lines = ["_"] * len(secret_word) mistakes = [] lives = 2 * len(secret_word)  print(guess_lines)  user_guess = input("guess letter: ")  while(lives != 0)        if user_guess in sw_list:         = sw_list.index(user_guess)         del guess_lines[i]         guess_lines.insert(i, user_guess)         print(guess_lines)         print("lives: ", lives)         print("mistakes: ", mistakes)         if "_" not in guess_lines:             break     else:         mistakes.append(user_guess)         print(guess_lines)         lives = lives - 1         print("lives: ", lives)         print(mistakes)  __ask__() 

your problem line before return missing closing square bracket ]. python thinks you're still inside brackets when line 5, , placing return inside brackets syntax error.

this common problem - if syntax error on line looks fine, it's worthwhile @ previous line, , see if line might being considered part of that.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -