KnowledgeBoat Logo

Computer Science

What will be the output produced by following code fragments?

x = "hello" + \
"to Python" + \
"world"
for char in x :
    y = char
    print (y, ' : ', end = ' ')

Python

Python String Manipulation

30 Likes

Answer

h  :  e  :  l  :  l  :  o  :  t  :  o  :     :  P  :  y  :  t  :  h  :  o  :  n  :  w  :  o  :  r  :  l  :  d  : 

Working

Inside the for loop, we are traversing the string "helloto Pythonworld" character by character and printing each character followed by a colon (:).

Answered By

17 Likes


Related Questions