Computer Science
Answer
Strings are sequence of characters where each character has a unique index. This implies that strings are iterable like lists but unlike lists they are immutable so they cannot be modified at runtime. Therefore, strings can't be considered as character lists. For example,
str = 'cat'
# The below statement
# is INVALID as strings
# are immutable
str[0] = 'b'
# Considering character lists
strList = ['c', 'a', 't']
# The below statement
# is VALID as lists
# are mutable
strList[0] = 'b'
Related Questions
What is the result of following statement, if the input is 'Fun'?
print(input("…") + "trial" + "Ooty" * 3)
Which of the following is not a Python legal string operation?
(a) 'abc' + 'abc'
(b) 'abc' * 3
(c) 'abc' + .3
(d) 'abc.lower()Given a string S = "CARPE DIEM". If n is length/2 (length is the length of the given string), then what would following return?
(a) S[: n]
(b) S[n :]
(c) S[n : n]
(d) S[1 : n]
(e) S[n : length - 1]From the string S = "CARPE DIEM", which ranges return "DIE" and "CAR"?