• Python question of the day

    What would be the output of executing the following code:
    s1 = 'ppy!'
    f1 = 'a'.join(list(s1))
    print(f1)
     appy
     appy!
     papaya
     papaya!
    Explanation:
    In python, if you pass a string to the list constructor it creates a list with the elements the characters from the string. The string method join(list) can be called on a string with a list of strings/characters as input. The result is a single string where the list elements are interleaved with the string you called join() on.


    Top 100 python interview questions:


  • python bootcamp 2021
datai analytics