Python Forum
Homework problem - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Homework problem (/thread-3404.html)



Homework problem - Dem_Prorammer - May-20-2017

(Basically the task)
Write a program that displays n flags for a given number n from 1 to 9. The image of one flag has a size of 4 × 4 characters, and between two adjacent flags there is also an empty (from spaces) column. It is allowed to output an empty column after the last flag. Inside each flag, its number must be written - a number from 1 to n.

How the flag looks like:
+___
|1 / 
|__\ 
|    
(My code)
n = int(input())
p_1="+___ "
print(p_1*n, sep='')
for i in range(1,n+1):
    print("|",i," / ",sep='')
p_3="|__\\ "
print(p_3*n)
p_4="|    "
print(p_4*n ,'\n')
So i having a problem when i enter a number, that's bigger than 1 something strange happens:
+___ +___ 
|1 / 
|2 / 
|__\ |__\ 
|    |



RE: Homework problem - ichabod801 - May-20-2017

There is an end parameter to end, that is displayed after everything else. It defaults to '\n', so normally print always goes to a new line when it's done. Using end = '' in the print in the for loop will solve your problem.