Hi i am new in python,i have just got a question below
A friend of yours has just bought a new computer. Until now, the most powerful computer he had
ever used was a pocket calculator. Now, looking at his new computer, he is a bit disappointed,
because he liked the LC-display of his calculator so much. So you decide to write a program
that displays numbers in an LCD-like style on his computer.
Input
The input file contains several lines, one for each number to be displayed. Each line contains two
integers s and n ( 1 ≤ s ≤ 10, 0 ≤ n ≤ 99 999 999), where n is the number to be displayed and s
is the size in which it shall be displayed. The input file will be terminated by a line containing
two zeros. This line should not be processed.
Output
Output the numbers given in the input file in an LCD-style using s ‘-’ signs for the horizontal
segments and s ‘—’ signs for the vertical ones. Each digit occupies exactly s+2 columns and
2s+3 rows. (Be sure to fill all the white space occupied by the digits with blanks including the
last one.) There has to be exactly one column of blanks between two digits. Output a blank
line after each number.
Sample Input:
2 12345
3 67890
0 0
Here is my code for one input but it gives me something else
n=raw_input()
n=n.split(' ')
s=int(n[0])
i=0
for i in n[1]:
p=int(i)
if(p==1 or p==4):
print ' '*s,
elif(p==2 or p==3 or p==5 or p==6 or p==7 or p==8 or p==9 or p==0):
print '-'*s
for i in n[1]:
p=int(i)
if(p==1 or p==2 or p==3 or p==7):
while(i<s):
print ' '*(s-1),'|'
i+=1
i=0
elif(p==5 or p==6):
while(i<s):
print ' |'
i+=1
i=0
else:
while(i<p):
print ' |',' '*(s-1),'|'
i+=1
i=0
for i in n[1]:
p=int(i)
if(p==1 or p==0):
print ' '*s
else:
print ' -'*s
for i in n[1]:
p=int(i)
if(p==1 or p==7 or p==3 or p==4 or p==5 or p==9):
while(i<s):
print ' '*s,'|'
i+=1
i=0
else:
while(i<p):
print ' |',' '*(s-1),'|'
i+=1
i=0
for i in n[1]:
p=int(i)
if(p==1 or p==4):
print ' '*s,
elif(p==2 or p==3 or p==5 or p==6 or p==7 or p==8 or p==9 or p==0):
print '-'*s
Note:
Do yourself and others a favor and don't use tabs for indentations, use the usual 4 spaces instead. We have discussed that plenty of times here on the forum, there are distinct benefits.