1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | class banner: def __init__ (self,text,style): self.text=text self.style=style def display(self): a1=" ## " a2="# # " a3="#### " a4="# # " a5="# # " A=[a1,a2,a3,a4,a5] e1="#### " e2="# " e3="#### " e4="# " e5="#### " E=[ e1, e2, e3, e4, e5] c1="#### " c2="# " c3="# " c4="# " c5="#### " C=[ c1, c2, c3, c4, c5] s1="#### " s2="# " s3="#### " s4=" # " s5="#### " S=[ s1, s2, s3, s4, s5] j=0 while j<5: i=0 while i<len(self.text): if self.text[i]=="A": A[j]=replace_one(A[j],"#",self.style) print(A[j],end='') if self.text[i]=="E": E[j]=replace_one(E[j],"#",self.style) print(E[j],end='') if self.text[i]=="C": C[j]=replace_one(C[j],"#",self.style) print(C[j],end='') if self.text[i]=="S": S[j]=replace_one(S[j],"#",self.style) print(S[j],end='') i+=1 print() j+=1 def setStyle(self,style): self.style=style def setup(): text=input("input text:") B=banner(text,"+") B.display() B.setStyle("*") B.display() B.setStyle("#") B.display() def replace_one(t,s,r): i=0 text="" while i<len(t): if t[i]!=s: text+=t[i] else: text+=r i+=1 return text setup() |
https://repl.it/BUU7