+2

What is the output?

Str="spoyl" x=str [::2] y=str [2]+str [1::2] print (x+y)

2/14/2020 3:08:40 PM

Devi Kamaraj..😉

6 Answers

New Answer

+6

******************* _________________ Output is: solopy _________________ ******************* # step +2 because str[::2] then.. str="spoyl" | | | 0 2 4 | | | . . . x= s o l _______________ str ="spoyl" | 0 1 2 3 | . str[2] = o ---------- # first index 1 then step +2 because str[1:2] then.. str="spoyl" | | 1 3 | | . . str[1:2]= p y ----------- y = str[2] + str[1:2] y = "opy" _____________________ x + y = "solopy"

+4

Devi Kamaraj..😉 Did you understand ?

+3

Change Str to str. Run this code https://code.sololearn.com/cxHFj1AJNp5g/?ref=app

+3

Great....thanks a lot

+2

I want to know the full explanation...can you define it..thanks for your response

+2

Yes...of course...its clear...thanks 😊