Computer Science
Consider the following code and find out the error:
tup1 = ("Riya", ) * '4'
Python Tuples
1 Like
Answer
The code will result in an Error because the multiplication operator * is being used incorrectly between a tuple and a string. The multiplication operator * in Python is used to repeat the elements of a tuple a certain number of times, but the number of repetitions must be an integer, not a string.
Answered By
3 Likes
Related Questions
Consider the following code and find out the error:
tup1 = (10, 20, 30) tup2 = tup1 * (3, )Consider the following code and find out the error:
tup1 = ('a', 'b', 'c') tup1 = tup1 + dConsider the following code and find out the error:
t1 = (10, 20, 30, 40) X, Y, Z = t1Consider the following code and find out the error:
tup1=('A', 'school', 10.5, 70) print max(tup1)