Web Analytics Made Easy -
StatCounter python input problem - CodingForum


No announcement yet.

python input problem

  • Filter
  • Time
  • Show
Clear All
new posts

  • python input problem

    this code is being difficult with me. It says that the " mark by the word "are" is wrong..but i dont know why. I tried to seperate the " marks and commas but that didn't seem to help much.

    print "Welcome to my program "
    print "Please type your name, age, city, state, and zip,"

    name = input("name ")
    age = input("age ")
    city = input("city ")
    state = input("state ")
    zip = input("zip ")

    print "Your name is", name "you are", age "years old and live in", city , state, zip
    print "Thank you for joining us!."

  • #2
    PHP Code:
    print "Welcome to my program "
    print "Please type your name, age, city, state, and zip,"

    name input("name ")
    age input("age ")
    city input("city ")
    state input("state ")
    zip input("zip ")

    "Your name is"name "you are"age "years old and live in"city statezip
    print "Thank you for joining us!." 
    try adding the line
    PHP Code:
    print "Your name is %s your age is %s years old and live in %s %s %s" % (nameagecitystatezip
    other wise to use your print statment, don't use the double quotes, use single quotes and it should work.



    • #3
      Jason, it did not work, but thats ok..i'll keep working at it.. was wondering what does the %s mean?


      • #4
        %s basically says you are using a string variable....so if you were using an int it would be %i and double/floats are %f extended florats are %ef or something...but then at the end you say what variables go in the order in which you use the variables...

        print "%s %i %s %s %i " % (name, age, city, state, zip)

        where name = string
        age = int
        city = string
        state = string
        zip = int

        and they correspond to the porper var call, maybe try taking the '%' out that seperates the vars and the printing string.....