skip to Main Content

so here ı am trying to learn modules in python ı am creating a greeting message but it keeps giving me an expression eror even though it doesnt seem to haveyour text any mistakes(names are a bit stupid but still)

from nabercanokolpacino import nabero
from bye import oldcustomer
print("are you new here?(answer yes or no)")
x=input(">>")
if x=="yes":{
    global o 
    o = input("name:");
    nabero(o)
}
elif x=="no":{
   oldcustomer()
}

as you can see above this should be printing me some stuff inside a function from nabercanokolpacino and bye if ı said yes or no but its nowt working because of the expession error

3

Answers


  1. Remove the curly brackets.

    from nabercanokolpacino import nabero
    from bye import oldcustomer
    
    print("Are you new here? (answer yes or no)")
    answer = input(">> ")
    if answer == "yes":
        name = input("name:")
        nabero(name)
    
    elif answer == "no":
       oldcustomer()
    
    Login or Signup to reply.
  2. There are many errors in your code, hover the mouse over the red line to see the error message.

    enter image description here

    Simple modified code:

    from nabercanokolpacino import nabero
    from bye import oldcustomer
    print("are you new here?(answer yes or no)")
    x=input(">>")
    if x=="yes":
        global o 
        o = input("name:")
        nabero(o)
    
    elif x=="no":
       oldcustomer()
    

    Also make sure to use a python interpreter with nabercanokolpacino and bye installed.

    You need to install the extension python.

    https://code.visualstudio.com/docs/python/python-tutorial

    Login or Signup to reply.
  3. There are a lot of syntax mistakes in your code. Your need to remove the curly braces. Modified code:

    #Import modules
    from nabercanokolpacino import nabero
    from bye import oldcustomer
    
    #Get user input
    print("Are you new here?(answer yes or no)")
    x = input(">>")
    
    #Check user input
    if x == "yes":
        global o 
        o = input("name:");
        nabero(o)
    
    elif x == "no":
       oldcustomer()
    

    Now you need to make sure that you have installed the nabercanokolpacino and oldcustomer modules to your Python interpreter.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search