+ 6
What is the output this code ?đđWhy??
x=int('22143'[3]) print(x) Output-4 I still confusion why come it's value 4 . Guys please explain me as detailed.
4 Answers
+ 4
Remember that here it is 0 based indexing system so start from 0 and go to point you need
+ 3
It first finds the substring indexed as 3rd place --> i.e. the forth object --> the forth object is '4'; it then converts it to an integer then prints it
+ 3
Index is 0 based...
+ 2
đSÄñtösh MĂ rĂ viđ
>x=int('22143'[3])
Here,
Index 0 have value 2
Index 1 have value2
Index 2 have value 1
Index 3 have value 4
Index 4 have value 3
Therefore '22143'[3]='4' #string
And int('22143'[3])=4 # interger
Therefore the output is 4..... :)