0

How multiplication of string and Integer is Possible in Python?? So confusing!!

X="a" Y=int(4) print(X*Y) output=aaaa

23rd Dec 2022, 6:03 PM
Amit Joe
Amit Joe - avatar
7 ответов
+ 3
Yes. X string appended Y times itself..
23rd Dec 2022, 6:13 PM
Jayakrishna 🇮🇳
+ 3
Multiplication of a string with an integer n returns the string n times, and the output string has a total length of n*len(string)
23rd Dec 2022, 6:31 PM
UnknownX
UnknownX - avatar
+ 3
doing this task is not confusing: text = input() # input a text / word e.g.: 'abc' (do not input the quotes) repeat = int(input()) # input a number e.g.: 3 print(text * repeat) # output will be a string 'abcabcabc' text contains the input 3 times
23rd Dec 2022, 8:58 PM
Lothar
Lothar - avatar
+ 2
x=banana y=int(input()) Answer= (x*y) Print("answer") #bananabananabananabanana or would that be str? it's confusing 🤣
23rd Dec 2022, 6:38 PM
Oddly Satisfying
Oddly Satisfying - avatar
+ 1
Right, you explained it so well. Not confusing at all 😂
23rd Dec 2022, 9:17 PM
Oddly Satisfying
Oddly Satisfying - avatar
24th Dec 2022, 11:17 PM
Erfnsko Fifieie
Erfnsko Fifieie - avatar