Example:
num_1 = 1010num_2 = 1234num_3 = 1034Here
num_1is the only valid number since it has both 1s and 0s.
num_2is invalid because it does not have any 1s or 0s.
num_3should also be invalid since it has digits other than 0s and 1s which are 2 and 4.Note: you cannot use any
forloops orwhileloop or any python function or method or string methods or built-in python methods all you can use areifelifandelse.
All I can use are Conditional statements if, if-else and if-elif-else Simple variable assignment ,Binary operators like and, or and not. I am not supposed to use Any Python method or function. Any Python loop structure. Any list, array, set, or dictionary object.
How can we solve this to find the number which has only 1s and 0s in it?
The given integer can be in between the range 0 and 10000.