diff --git a/1-hello-world/03_pattern.py b/1-hello-world/03_pattern.py index 1ed538d..08e1aa2 100644 --- a/1-hello-world/03_pattern.py +++ b/1-hello-world/03_pattern.py @@ -2,3 +2,25 @@ print(' 2 3') print(' 4 5 6') print('7 8 9 10') + +#the way I coded +# Write code below 💖 + +''' +1 +2 3 +4 5 6 +7 8 9 10 +I used the for loop with enumerate function to iterate over the list +''' + +a = [1,2,3,4,5,6,7,8,9,10] +for count, item in enumerate(a,start=1): # here we are setting the index 0 as 1 + if(count == 1): + print(item) + if(count == 2): + print(item,a[count]) + if (count == 3): + print(a[count],a[count+1],a[count+2]) + if (count == 4): + print(a[count+2],a[count+3],a[count+4],a[count+5]);