+ 2

letter pattern python

https://www.sololearn.com/compiler-playground/c1Aib1aN4z11 I want it looks like this: A B C D E F G H I J K L M N O

20th Oct 2022, 3:23 PM
STOP
STOP - avatar
11 Respostas
+ 4
def alphapat(n): num = 65 for i in range(0, n): for j in range(0, i+1): ch = chr ( num ) print(ch , end=" ") num = num + 1 #inside inner loop. print("\r") n = 5 alphapat(n)
20th Oct 2022, 4:02 PM
Jayakrishna 🇮🇳
+ 4
Bob_Li '\r' is a carriage return escape character it works differently on different operating system. On linux it works like backspace but on windows it works similar to '\n' i.e. new line character
21st Oct 2022, 6:34 AM
Binx
Binx - avatar
+ 2
Jayakrishna🇮🇳 cool code😎 I never understood what print('\r') does, though. print() seems to work ok. Btw, did Sololearn add a codeblocker in the reply form? I get this no connection message and cannot submit when my reply contains code... But you obviously can do it. very strange.🤔 and if I copy paste your code, i can submit it. even stranger.😲😲 Anyway, I made some modification in your code to keep the range in the capital letters if n is large. https://code.sololearn.com/c7uC5oK2O14W/?ref=app
20th Oct 2022, 11:17 PM
Bob_Li
Bob_Li - avatar
+ 1
Its start from b when i add it inside inner loop Jayakrishna🇮🇳
20th Oct 2022, 3:56 PM
STOP
STOP - avatar
+ 1
Bob_Li As @Snehil said, '\r' is carriage return works depends on operating system. Here it won't work. Am not added it. OP trying it in System. So it it works there.. I just edited code to work it properly as expected output. Also yes, I faced same trouble and find that chr function is blocking to add code so added a space=> chr () . Reason I don't know, I already asked Sololearn staff and other senior mentors and waiting for their response.
21st Oct 2022, 9:20 AM
Jayakrishna 🇮🇳
+ 1
❓❓chr ()❓❓ or gvhgvvbhvbvg chr ()hhbvgcv Jayakrishna🇮🇳 you are right. remove the space between 'chr (' and it blocks. also the chr must have a space before it.
21st Oct 2022, 9:37 AM
Bob_Li
Bob_Li - avatar
+ 1
Bob_Li Yes. Trying without a space between, it's blocking.
21st Oct 2022, 9:39 AM
Jayakrishna 🇮🇳
0
Add num += 1 inside inner loop. Not after..
20th Oct 2022, 3:53 PM
Jayakrishna 🇮🇳
0
some trouble in replying... pls wait.
20th Oct 2022, 3:58 PM
Jayakrishna 🇮🇳
0
STOP done. Faced trouble in adding..
20th Oct 2022, 4:09 PM
Jayakrishna 🇮🇳
0
Hii
21st Oct 2022, 1:46 PM
HACKER
HACKER - avatar