Programmer's way of thinking is from XX book (Python)

Since you commented on the post the other day, I immediately made use of my reflection I will do my best to continue the reference book (while googled (´Д`))

Display half of the square > Using only two output statements, textcout << "#" and cout << "\ n", Hash symbol (#) for a 5 x 5 square Let's write a program to make a half shape (right triangle)

Answer ``` >>> str = '#####' >>> for i in range(5,0,-1): ... slice = str[:i] ... print(slice) ... ##### #### ### ## # >>>

 By the way, I don't know the for sentence, but while moving the previous comment with copy
 I adjusted it.

 If it is a while statement

str = '#####' i = 5 while i > 0: ... slice = str[:i] ... print(slice) ... i -= 1 ...


 What do you think?
 I will continue next time.


Recommended Posts

Programmer's way of thinking is from XX book (Python)
Programmer's way of thinking is from XX book (Python)
From a book that makes the programmer's way of thinking interesting (Python)
From a book that programmers can learn ... (Python): Pointer
I'm thinking of studying Python
From a book that programmers can learn ... (Python): About sorting
From a book that programmers can learn (Python): Decoding messages
Existence from the viewpoint of Python
Python3 compatible memo of "python start book"
From a book that programmers can learn (Python): Statistical processing-deviation value
What is the XX file at the root of a popular Python project?
From a book that programmers can learn (Python): Conditional search (maximum value)
What kind of book is the best-selling "Python Crash Course" in the world?
Find out the name of the method that called it from the method that is python
From a book that makes the programmer's way of thinking interesting (Python)
[python] [meta] Is the type of python a type?
Learning notes from the beginning of Python 2
From a book that programmers can learn: Verification of rune checksum (fixed length)
From a book that programmers can learn (Python): Class declaration (public / private, etc.)
Get the contents of git diff from python
A memorandum of calling Python from Common Lisp
I tried Python! ] I graduated today from "What is Python! Python!"!
This is the only basic review of Python ~ 1 ~
This is the only basic review of Python ~ 2 ~
This is the only basic review of Python ~ 3 ~
Let's use different versions of SQLite3 from Python3!
An easy way to call Java from Python
From a book that programmers can learn ... Verification of rune checksum (variable length) Part 2