Skip to content
Advertisement

How to access first n characters of a key value in Python

I need to access the first 10 characters of a key-value in dictionary. My dictionary looks like this:

JavaScript

I have tried:

JavaScript

The desired output is:

JavaScript

Advertisement

Answer

Why are you using a loop? You can do this directly:-

JavaScript

Output:-

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement