0
A little help needed.Can you print these series in a same loop(can use nested loop)
(Program im c,cpp,python,php is appreciated(i know these only) here is the series 0000 0001 0002 0003 0004 . . . 0010 . . . . 0100 0101 0101 . . . 9000 . . . . 9998 9999 I tried the for loop ( for i=0000;i<=9999;i++) . but the number is only starting from 1 instead of 0001. i know my code doesn't work like what i meant to be. The thing is i need this series to print only using one loop only.( loop in a loop is ok. but dont use another loop is outside the first loop. i think you get it.)
3 Antworten
+ 3
https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/string_zfill.htm
Syntax: str.zfill(width)
Example:
str.zfill(4)
^Ensures it's 4 in length, so if it's 1 it'll be 0001. etc... Use simple loop, nested not needed.
+ 2
Try with that but not in SL Playground because its not finish for SL limits
https://code.sololearn.com/wS8V8aLfUyr8/?ref=app
0
heres a python solution
[print("0"*(4-len(str(i)))+str(i)) for i in range (1,200)]