0

Just messing around trying to learn things.
Made this dumb program. Just want tp and socks to both be true for you to be able to get the if thing. Or idk.

def shit_supplies(tp, socks, time):
    print "Time: %d minutes" % time
    print "Soks on? %r" % socks
    print "Butt-Wipies? %r" % tp
if tp socks == "true":
    print "Hurry up only %d minutes to pinch it off!!@!" % time
else:
    print "No poopies for you!"

Tried a few things like commas and such to get it to work but I am lost and can't find it on googles.

tbhm
  • 21
  • 1
    What you are looking for are logical operators in Python. I would suggest you to read through the basics here: https://www.tutorialspoint.com/python/logical_operators_example.htm – Setup Jun 01 '17 at 07:23
  • could you give an example – Stavros Avramidis Jun 01 '17 at 07:23
  • The way you do this you're comparing with a string (`"true"`). What you need is this: `if tp == True and socks == True:` – trotta Jun 01 '17 at 07:23
  • "The way you do this you're comparing with a string ("true"). What you need is this: if tp == True and socks == True: – trotta" this worked ty!! – tbhm Jun 01 '17 at 07:27
  • 2
    can you please edit the question to remove the bad language? – WhatsThePoint Jun 01 '17 at 07:37

1 Answers1

3

There is just a few small mistakes within your attempt.

 def poop_supplies(tp, socks, time):
        print("Time: %d minutes" % time)
        print("Soks on? %r" % socks)
        print("Bottom-Wipies? %r" % tp)
        if tp and socks:
            print("Hurry up only %d minutes to pinch it off!!!" % time)
        else:
            print("No poopies for you!")

Here is a nice little tutorial on boolean operators.

Shaun Barney
  • 718
  • 10
  • 24
  • 3
    No point in doing identity comparisons with booleans. Just `if tp and socks:` would do. That'll allow passing None and other falsy values as well. – Ilja Everilä Jun 01 '17 at 07:27
  • cool. ty guys for the help! and for the tutorials. I learned a few ways to make it work now! – tbhm Jun 01 '17 at 07:34