English

Predict the output of the following code: d = {"apple": 15, "banana": 7, "cherry": 9} str1 = "" for key in d: str1 = str1 + str(d[key]) + "@" + “\n” str2 = str1[:-1] print(str2) - Computer Science (Python)

Advertisements
Advertisements

Question

Predict the output of the following code: 

d = {"apple": 15, "banana": 7, "cherry": 9}
str1 = ""
for key in d:
      str1 = str1 + str(d[key]) + "@" + “\n”
str2 = str1[:-1]
print(str2)
Short Answer

Solution

15@
7@
9

shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×