0
tried one
when i assigned x=7 and used operation print(âxâ*7) ,why its showing x 7 times as output ,it should be 7 ,7 times right?
2 Answers
+ 6
print("x"*7): doesn't care about your variable x, prints "x" seven times in a row # xxxxxxx
print(x*7): prints value of variable x times seven # 49
print(str(x)*7): converts value of x to a string and prints it seven times in a row # 7777777
+ 1
"x" is a string thus it doesn't use the value of the x variable.
Please check the 3rd page of the link to find out why you got that output:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2427/?ref=app