python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

python

what is the result of this code? >>x="a" >>x*=3 print(x)

27th Feb 2020, 8:25 PM
Zainab Chaudhary
Zainab Chaudhary - avatar
3 Answers
+ 3
error because a is not defined
27th Feb 2020, 8:27 PM
Oma Falk
Oma Falk - avatar
+ 3
When you multiply an integer of value x with a string, it simply concatenate the string with itself x times(where x is the integer value). >>>s = 'spam' >>>r = s *3 >>>r "spamspamspam" And in your example value of x is "aaa".
27th Feb 2020, 9:08 PM
M3hran
M3hran - avatar
- 1
27th Feb 2020, 8:37 PM
Zainab Chaudhary
Zainab Chaudhary - avatar