0

[SOLVED] Python code not working. Help!?

I'm trying to solve a SoloLearn challenge, but there is a mistake in my code that I can't find. Could you help me, please? Input: November 19, 2021 >> aaaa=date[-5:-1] Output [expected]: 2021 Output [real]: _202 https://code.sololearn.com/cq773qkPe5i1/?ref=app

11th Mar 2021, 9:44 PM
ā–²TopGun ā–²
ā–²TopGun ā–² - avatar
2 Answers
+ 2
You are using slicing the wrong way for what you want , -5:-1 tells python to slice elements starting from index -5 and stop before -1 . You should use [-4:]
11th Mar 2021, 10:36 PM
Abhay
Abhay - avatar
+ 1
Thanks Abhay it is well working now
11th Mar 2021, 11:19 PM
ā–²TopGun ā–²
ā–²TopGun ā–² - avatar