Jump to content
dil_bert

IndentationError: expected an indented block

Recommended Posts


 

 
HELLO Dear all - i have the code below running but it gets errors


File "/home/martin/.PyCharmCE2018.2/config/scratches/p1_.py", line 3
    phoneBook = {}
            ^
IndentationError: expected an indented block

Process finished with exit code 1

see the code below 
 
def main():

phoneBook = {}
name = input("Please enter a name(or press enter to end input): ")
while name != '':
    number = input("Please enter number: ")
    phoneBook[name] = number
    name = input("Please enter a name(or press enter to end input): ")
    if name == '':
        print("Thank You!")

print("Your phonebook contains the following entries:\n",phoneBook)


main()

 

Edited by dil_bert

Share this post


Link to post
Share on other sites

Look at it

def main():

phoneBook = {}

and tell me what the #1 rule of Python code is.

Share this post


Link to post
Share on other sites
20 hours ago, requinix said:

Look at it


def main():

phoneBook = {}

and tell me what the #1 rule of Python code is.

 

    an indented block

?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.