1

Hello I am new to the world of programming and I need a bit of help. I was trying to finish some work that I had to do for my Python class and I came across a problem that I couldn't fix and couldn't find answers on the web for. Here is my problem. When I code something like:

a = "apples"
t = "tomatoes"
answer = raw_input("Do you prefer eating ", p," or ", t, " ?")
print answer

It gives me an error message on line 3 saying: "TypeError: Win32Input() takes at most 2 arguments (6 given)" What did I do wrong and how can I fix it? Thanks in advance. :)

1
  • If you're new to Python, I'd seriously recommend that you start with Python 3 as it is the more newbie-friendly choice. Commented Oct 30, 2016 at 19:22

1 Answer 1

2

raw_input's input is not the same as print's, it takes a string, so you have to create a string by formatting it:

answer = raw_input("Do you prefer eating {} or {}?".format(p, t))
Sign up to request clarification or add additional context in comments.

6 Comments

Thank you very much for taking the time to answer my question.
But when i tried to insert your line of code I got this error message: ValueError: zero length field name in format
@MatthieuChapeland Looks like you're using Python 2.6, replace {} or {} with {0} or {1}
It worked! Thank you very much! I can finish my work now! You've been a great help. :)
How do I do that? I'm new to this site.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.