For loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

For loop

1,2,3,1,4,5,6,2,7,8,9,3.......N Print out this series using loop ?

3rd Jun 2021, 7:24 AM
DURGESH RAWAT
DURGESH RAWAT - avatar
3 Answers
+ 1
Try it this solution: n = int(input()) save = 1 for k in range(1, n + 1): count = 0 for t in range(save, 3*n + 1): if count == 3: save = t break print(t) count += 1 print(k) This code print the following result: 123145627893... It depends of n input value
3rd Jun 2021, 3:02 PM
CLAD
CLAD - avatar
+ 1
should N be the first occurence of it or the count/index of the term (Nth... in wich case should start at zero or at one)? I guess that's the former (more challenging), but it's quite unclear ^^
3rd Jun 2021, 9:32 AM
visph
visph - avatar
0
DURGESH RAWAT Where is your attempts? Be like this person "Bill" https://www.sololearn.com/post/1115272/?ref=app
3rd Jun 2021, 7:38 AM
A͢J
A͢J - avatar