1

I am a newbie to Python, what am I doing wrong?

if p1_teller == 0 & p1_raw[0:1] != "/":
    print "Loop 1"
else:
    print "Loop 2"

Then I get the following error:

TypeError: unsupported operand type(s) for &: 'int' and 'str'

1
  • 3
    Use and instead of &. Commented Nov 10, 2013 at 13:13

3 Answers 3

6

Python uses and for logical and. & is a bitwise and. Change your code to:

if p1_teller == 0 and p1_raw[0:1] != "/":
    print "Loop 1"
else:
    print "Loop 2"
Sign up to request clarification or add additional context in comments.

Comments

0

A brief google search shows python using 'and' for its operator, not &

1 Comment

you can use & in python also, it just doesn't mean the same thing and is not applicable in this case
0

Use and instead of &
change this :

if p1_teller == 0 & p1_raw[0:1] != "/":  

to :

if p1_teller == 0 and p1_raw[0:1] != "/":

Comments

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.