I need solution for this pattern only use only one loop like only one for loop or only one while loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I need solution for this pattern only use only one loop like only one for loop or only one while loop

1 10 101 0101

15th Aug 2019, 7:42 PM
RAJANBABU V
RAJANBABU V - avatar
6 Answers
+ 3
if the pattern is 1 10 101 0101 10101 101010 1010101 01010101 101010101 (since no language given it will be Python because it's short): s = "1" m = 10 for i in range(m): if i % 4 == 0: s = s + "0" elif i % 4 == 1: s = s + "1" elif i % 4 == 2: s = "0" + s else: s = "1" + s print(s) (if it's a diffrent pattern, write more of it and write which language you actually need ...)
15th Aug 2019, 8:00 PM
Anton Böhler
Anton Böhler - avatar
+ 2
Thank you sir
15th Aug 2019, 8:01 PM
RAJANBABU V
RAJANBABU V - avatar
+ 2
Anton Böhler People need to learn how to ask questions properly :p
15th Aug 2019, 8:04 PM
Tibor Santa
Tibor Santa - avatar
15th Aug 2019, 8:02 PM
Tibor Santa
Tibor Santa - avatar
0
Tibor Santa well it's not wrong 😂😂😂
15th Aug 2019, 8:03 PM
Anton Böhler
Anton Böhler - avatar
0
How to print using for loop in python 1010101 10101 101 1
17th Apr 2020, 3:25 PM
Sneha S N