How are strings stored in python?

I want to know whether strings are stored as ASCII values or not .
Are strings ended with ‘\n’
Thank you

There is usually no need to check for '\0'. If we wanted to iterate over a string s, we would do something like this:

for i in s:
    print i

or whatever u wish to do with the element i.

1 Like

‘\0’ u mean?

1 Like

You cannot directly do ASCII code based arithmetic on string characters in Python. Use
function ord() to get the ASCII code of a character.
For ex.

print ord('a')

prints 97

Just wonreding 'a' - 0 won’t do the same?

Nope. It gives a TypeError.

1 Like