+ 7
What is the output?
Str="spoyl" x=str [::2] y=str [2]+str [1::2] print (x+y)
6 Réponses
+ 8
*******************
_________________
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"
+ 7
Great....thanks a lot
+ 6
I want to know the full explanation...can you define it..thanks for your response
+ 6
Devi Kamaraj..😉 Did you understand ?
+ 6
Yes...of course...its clear...thanks 😊
+ 5
Change Str to str.
Run this code
https://code.sololearn.com/cxHFj1AJNp5g/?ref=app