• Python question of the day

    Which of the following code snippets, when executed, will NOT give the output
    ['Hello', 'World']
     x = ['Hello']; x.append('World'); print(x)
     x = ['Hello']; x.insert(1, 'World'); print(x)
     x = ['Hello']; x.extend('World'); print(x)
     x = ['Hello']; x = x + ['World']; print(x)
    extend method takes iterable as argument and iteratively appends each element to the list. so ['Hello', 'W', 'o', 'r', 'l', 'd'] would be the output when x = ['Hello']; x.extend('World'); print(x) is executed

    Top 100 python interview questions:

  • python bootcamp 2021
datai analytics