How to print the numbers given below without using any conditional statements? The set of numbers: var=01120221011202210112.

Login

0 votes

Here is the easiest way to print the number 01120221011202210112 without using conditional statements:

a='1011'

b='2022'

s = a+b+a+b+a+b

s[1:-3]

**Explanation**: If you observe, 10112022 pattern is repeating through the variable, So, initialize a as '1011' and b as '2022'. Concat a+b three times. After that sub-string the result string from 2nd character until the last 3rd character.

If you are interested to learn Python, I would recommend this Python Training course Intellipaat which has experienced instructors, the best curriculum, and projects.