Hi there

Im doing a project at the moment and need to find the numbers 1,2 and 3 i(all) in any order entered by the user.

lengthOfList = int(input("Enter the number of elements:"))

for i in range(0,lengthOfList):
elm = int(input("Enter and element value: "))


Code so far, just need help with the functions



Recommended Answers

All 5 Replies

In psuedo code something like:
if 1 in B and 2 in B and 3 in B do something.

Looks like you need something like this one liner to test for that.

Thank for this code.

I have tried it and it nearly works, but if you do two of the three numbers, it returns a yes.

All need all three to be present.

Thank you

You could use

if all(x in A for x in (1, 2, 3)):


if set((1, 2, 3)).issubset(A):


if 3 == len(set(range(1, 4)) & set(A)):

This smells like (not teen spirit) sets! Have a look on sets and Python and I guess your problems will be solved. Success!

Be a part of the DaniWeb community

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