Advertisements
Advertisements
Question
Predict the output of the code given below:
def makenew(mystr):
newstr.=.""
count=0
for i in mystr:
if count%2 ! = 0:
newstr=newstr+str(count)
else:
if i.lower():
newstr = newstr + i.upper ()
else:
newstr = newstr + i
count+=1
Print(newstr)
makenew("No@1") Short Answer
Advertisements
Solution
N1@3
Explanation:
The function makenew() iterates through the characters in the provided string and generates a new string consisting of uppercases of the string characters and the values of a count or the original characters based on the values of the count and the cases of the characters in the string.
shaalaa.com
Is there an error in this question or solution?
