Results 1 to 3 of 3

Thread: Really n00bish python question

  1. #1
    Join Date
    Dec 2004
    Location
    Nova Scotia, Canada
    Beans
    184

    Really n00bish python question

    I was reading some Dive into Python for the first time and I was wondering why my simple name/string program doesn't work:


    print "Welcome"
    print
    name = raw_input("Please enter in your name: ")
    if name == "Jason" then
    print "Hello Jason!"
    else
    print "Go away!"

  2. #2
    Join Date
    Jan 2005
    Location
    Chesterfield UK
    Beans
    139

    Re: Really n00bish python question

    Quote Originally Posted by Gnobody
    I was reading some Dive into Python for the first time and I was wondering why my simple name/string program doesn't work:
    Your problem is missing ":" after if and else, also next isn't a keyword in python (iirc)
    your code should look more like this:
    Code:
    print "Welcome"
    print
    name = raw_input("Please enter in your name: ")
    if name == "Jason":
    	print "Hello Jason!"
    else:
    	print "Go away!"

  3. #3
    Join Date
    Dec 2004
    Location
    Nova Scotia, Canada
    Beans
    184

    Re: Really n00bish python question

    Quote Originally Posted by sas
    Your problem is missing ":" after if and else, also next isn't a keyword in python (iirc)
    your code should look more like this:
    Code:
    print "Welcome"
    print
    name = raw_input("Please enter in your name: ")
    if name == "Jason":
    	print "Hello Jason!"
    else:
    	print "Go away!"
    Wow, Python and Gedit pwn me. Now to learn PyGTK...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •