QuesAns Print Page – CSKC
Sign In

Search

siteicon
Q&A CBSE12D-2015-B02E #6530

Question:

Write a method in python to display the elements of list thrice if it is a number and display the element terminated with ‘#’ if it is not a number.

For example, if the content of list is as follows:
ThisList=['41','DROND','GIRIRAJ','13','ZARA']
414141
DROND#
GIRlRAJ#
131313
ZARA#

Answer:

def fun(L):
    for I in L:
        if I.isnumeric():
            print(3*I) # equivalently: print(I+I+I)
        else:
            print(I+'#')