I'm a beginner and I need help


So I just started trying to learn Python for a project and as a potential career path, below is a code I don’t know why isn’t working, my foundation might not be that good, can someone explain to me?

# Make sure that the_flying_circus() returns True
print "What is the truth?" 
answer = raw_input()
def the_flying_circus(answer):
    if answer == potato:    # Start coding here!
        if len(potato) == 6:
          cat = True
          if cat = True
            print "Potatoes are the truth"
        # the code inside this block!
    elif answer = potatoes:
        print "I want the singular form"
        print "What are you doing"

File “python”, line 8
if cat = True
SyntaxError: invalid syntax


You might want to test smaller pieces of code, grab the offending part, put it in its own file, verify that you still have the same issue, pick it apart into smaller pieces yet, compare what you’re doing to other code, google to get examples of what things should look like such as if-statements or comparing two values

Figure out what’s up and what’s down on a lego brick before combining it with others.


So I tried to improve it and I came to this,

print "What is the truth?" 
cat = raw_input()
def the_flying_circus(answer):
    if cat == potato:
            return "Potatoes are the truth"
            return True
    elif cat == potatoes:
        return "I want the singular form"
        cat = raw_input()
        return "What are you doing"
        cat = raw_input()

But it ends up saying the_flying_circus should not take any arguments and I have no idea what to do D:


What determines how many arguments your function accepts?

Stick with 4 spaces for indentation, not… that

Taking user input is probably more trouble than it’s worth here. If you wanna test your code I suggest hard-coding the test data instead of typing it in (though in this case, as your error message points out, there’s no data to input)

And very rarely should functions be taking user input themselves, a function should almost always only accept input through its parameters and only reply through its return value

I understand the want to write something interactive, but you’ll have an easier time with the exercises and their tests if you stay as close to what the instructions describe as you can. (Do it on your local system instead, and do it with programs where you’re the one deciding how they should behave rather than when you’re following specifications)


Thank you for your help!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.