Non-Working Doctors

Non-Working Doctors

A doctor survey results information is stored in 2 lists. First list represents doctors ids (working and non -working both). Second list represents only working doctor’s id. Please find the doctor ids who are not working.  Write a program in Python to perform the above task..

Input and Output Format:

First line of input corresponds to n1, the size of first list and next n1 lines correspond to the elements of the first list.

The next line corresponds to n2, the size of second list and next n2 lines correspond to the elements of the second list

Output is the id’s of doctor who are not working

Note:

  • Print “Invalid list size”,  if size of the list entered is a negative number  or zero and terminate the program
  • Print “Invalid Id” , if the id entered is any negative number  or zero and terminate the program.

Sample Input 1:

7

7

2

3

4

5

6

1

3

3

4

5

Sample Output 1:

Not Working Doctors’ IDs are:

7 2 6 1

Sample Input 2:

7

7

2

3

4

5

6

-1

Sample Output 2:

Invalid Id

Sample Input 3:

5

45

2

-5

Sample Output 3:

Invalid Id

Sample Input 4:

0

Sample Output 4:

Invalid list size

Sample Input 5:

3

67

44

33

-5

Sample Output 5:

Invalid list size

Sample Input 6:

3

15

36

78

2

0

Sample Output 6:

Invalid Id

Code :-

t=[]
w=[]
nw=[]
n=int(input())
if n>0:
    for i in range(n):
        a=int(input())
        if a<=0:
            print("Invalid Id")
            exit()
        t.append(a)
else:
    print("Invalid list size")
    exit()
m=int(input())
if m>0:
    for j in range(m):
        b=int(input())
        if b<=0:
            print("Invalid Id")
            exit()
        w.append(b)
else:
    print("Invalid list size")
    exit()
print("Not Working Doctors' IDs are:")
for i in t:
    if i not in w:
        print(i,end=" ")
                
                
        
        

1 thought on “Non-Working Doctors”

  1. great post, very informative. I wonder why the other specialists
    of this sector do not realize this. You should proceed your writing.
    I’m confident, you’ve a huge readers’ base already!

Leave a Comment

Your email address will not be published. Required fields are marked *

x