[Tutor] Why does invalid syntax pop up?

Terry Carroll carroll at tjc.com
Fri Jul 8 08:33:29 CEST 2005


On Thu, 7 Jul 2005, Nathan Pinno wrote:

>   Why does invalid syntax popup?


<snip>

>   def lookup_login_command(site,filename):
>       print "Lookup a login info card"
>           site = raw_input("Site: ")
>           if sitelist.has_key(site):
>               print "The ID is: ",sitelist[site][0]
>               print "The password is: ",sitelist[site][1]
>           else:
>               print site," was not found."

Bad indentation.  Try this instead:


def lookup_login_command(site,filename):
    print "Lookup a login info card"
    site = raw_input("Site: ")
    if sitelist.has_key(site):
        print "The ID is: ",sitelist[site][0]
        print "The password is: ",sitelist[site][1]
    else:
        print site," was not found."



More information about the Tutor mailing list