Hello, can someone please tell me why this simple if ststement dose not run

>>> VList=[0,0,1,0,1,1,0,0]
>>> if VList.count(1) < 5:
	print('Yes')
    else:
         print('No')

The VList.count(1)works so not sure what is wrong, but I think that's were the code is crashing.

Thanks

Recommended Answers

All 3 Replies

It works perfect here.

VList=[0,0,1,0,1,1,0,0]
if VList.count(1) < 5:
    print('Yes')
else:
    print('No')

My output:
Yes

You misindented blocks. If and else same indent, the code blocks one indent also same line. The prompt does not count.

In interactive mode:

>>> VList=[0,0,1,0,1,1,0,0]
>>> if VList.count(1) < 5:
	print('Yes')
else:
        print('No')

        
Yes

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.