English

Write a Python program to display the given pattern. C O M P U T E RC O M P U T E C O M P U T C O M P U C O M P C O MC O C

Advertisements

Question

Write a Python program to display the given pattern.

C O M P U T E R
C O M P U T E
C O M P U T
C O M P U
C O M P
C O M
C O
C

Short/Brief Note
Advertisements

Solution

Coding:

str 1=”COMPUTER”
index=len(str1)
for i in str1:
print(strl[0:index])
index-=1
Output:
>>>
RESTART: C:/Users/COMPUTER/
AppData/Local/Programs/Python/ Python37-32/compl.py ‘
COMPUTER
COMPUTE
COMPUT
COMPU
COMP
COM
CO
C
shaalaa.com
Programs Using Strings
  Is there an error in this question or solution?
Chapter 8: Strings and String manipulation - Evaluation [Page 130]
Advertisements
Share
Notifications



      Forgot password?
Use app×