+ 2
Anyone please help me printing the following pattern using single for loop in python.. 5...4 5....3 4 5...2 3 4 5....1 2 3 4 5
Input should be taken from the user. Please use single for loop.. Please help me in this
18 ответов
+ 4
sarada lakshmi 
I didn't helped you, no need for thanks
+ 4
Welcome sarada Lakshmi
+ 3
Please show us your attempt first so that we can help you..
+ 3
sarada lakshmi 
Please give me the pattern clearly....
or show us your attempt, so that we can understand the pattern
+ 3
sarada lakshmi Same here. Give all thanks to 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
+ 2
This is a good way 
r = 5
for i in range(r):
      print(range(n-i,n+i))
+ 1
꧁༒Rishabh༒꧂ and 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
My approach :
n=int(input())
for i in range(n) :
      for j in range(n-i, n+1):
              print(j, end=" ")
      print()
+ 1
Thanks alot 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 ,꧁༒Rishabh༒꧂ and  Ćheyat Thanks for helping me 👍
+ 1
In cpp we can do it like
int x=5;
for(int i=0;i<5;i++)
{
   for(int j=x-i;j<6;j++)
    {
       cout<<j<<" ";
    }
  cout<<endl;
}
+ 1
Thanks Dani N and Harsh Kant
0
sarada lakshmi Kindly Provide your attempt.
- 1
꧁༒Rishabh༒꧂ Ćheyat i can able to do it using 2 for loops.. But, not getting any idea to write the program using one for loop.. That's the reason why I posed question here.. If you know, please help me out..!!









