+ 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.

19th Jun 2020, 12:41 AM
SùñtÎsh
SùñtÎsh - avatar
4 Answers
+ 4
Remember that here it is 0 based indexing system so start from 0 and go to point you need
19th Jun 2020, 12:55 AM
Ayush Kumar
Ayush Kumar - avatar
+ 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
19th Jun 2020, 12:51 AM
Ali Abdelhady
Ali Abdelhady - avatar
+ 3
Index is 0 based...
19th Jun 2020, 4:17 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 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..... :)
19th Jun 2020, 1:03 AM
Indira
Indira - avatar