Computer Science
Find the errors(s)
name = "HariT"
print (name)
name[2] = 'R'
print (name)
Python Data Handling
34 Likes
Answer
The line name[2] = 'R'
is trying to assign the letter 'R' to the second index of string name but strings are immutable in Python and hence such item assignment for strings is not supported in Python.
Answered By
15 Likes
Related Questions
Given a string s = "12345". Can you write an expression that gives sum of all the digits shown inside the string s i.e., the program should be able to produce the result as 15 (1+2+3+4+5).
[Hint. Use indexes and convert to integer]Predict the output if e is given input as 'True':
a = True b = 0 < 5 print (a == b) print (a is b) c = str (a) d = str (b) print (c == d) print (c is d) e = input ("Enter :") print (c == e) print (c is e)
Find the errors(s)
a = bool (0) b = bool (1) print (a == false) print (b == true)
Find the errors(s)
print (type (int("123"))) print (type (int("Hello"))) print (type (str("123.0")))