0
Can you stay strings are character lists? why ? why not?
2 Respostas
+ 1
Strings are arrays of characters. This means that they are iterable like lists but unlike lists, they are immutable and cant be changed at runtime
However, Python cleverly hides all this behind the scenes unless you need to work with it
In more practical terms
# you can loop through strings
for c in "Hello World":
print(c)
# you can use slicing on them
reversed_string = old_string[::-1]
# but you cant change them
word = "Hello"
word[3] = 'p' # raises error
In lower level languages like C, you wouldve actually needed to make a char[] array to represent the string (no built in datatype for string unless Im remembering wrong)