How many stars (*) does the snippet print?
How many stars (*) does the snippet print?
The code is erroneous because the subtraction operator '-' is not supported for strings in Python. Only concatenation '+' and repetition '*' are allowed for strings. Therefore, attempting to use the '-' operator with strings will result in a TypeError.
A is answers. The snippet wiill generate a TypeError
Correct. TypeError will be thrown
A. the code is erroneous
s='*****' s= s - s[2] #TypeError: unsupported operand type(s) for -: 'str' and 'str' print(s) #For strings, only + ( concatenate ) and * (multiply) is allowed. TypeError will be returned #TypeError: unsupported operand type(s) for -: 'str' and 'str' #Ans: the code is erroneous
For strings, only + ( concatenate ) and * (multiply) is allowed. TypeError will be returned Ans: A
A is correct. strings support concatenation. '-' is not supported in strings
A. the code is erroneous is correct
-(minus) is not supported b/n 'str' and 'str', if +(plus) then it works, ex. s=s+s[2] then '******' six stars