Assignment
University
University of ReginaCourse
Computer Science (UR)Pages
2
Academic year
2023
priyankavaiya07
Views
0
Q2. Perform the following: a. Write a function called add_excitement that takes a list of strings and adds an exclamation point (!) to the end of each string in the list. The program should modify the original list and not return anything. b. Write the same function except that it should not modify the original list and should instead return a new list. def add_excitement1(l): for i in range(len(l)): l[i]=l[i]+"!" print(l) def add_excitement2(l): x=[] for i in l: i=i+"!" x.append(i) return x a=[] n=int(input("Enter the number of element in list: ")) for i in range(n): i=input("Enter the elements: ") a.append(i) print(a) print(add_excitement2(a)) print(a) add_excitement1(a) print(a)
String Excitement Functions: Modifying and Returning Lists
Please or to post comments