Can we multiply string with zero or negative integer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we multiply string with zero or negative integer

Well if we do this for example: >>>print("spam" * -1) >>>print(spam" * 0) Output is blank no that means no output displayed

24th Jul 2019, 1:34 PM
Vyoma Patel
Vyoma Patel - avatar
6 Answers
+ 4
HonFu [#GoGetThatBugChamp!] I thought the same
24th Jul 2019, 1:50 PM
deeyae
deeyae - avatar
+ 3
Yes, you can Vyoma Patel And the result is a blank for string, a blank tuple () for a tuple and a blank list [] for a list Eg: list = [34,45] tup = (34,45) print(list*0) print(tup*0) Output: [] ()
24th Jul 2019, 1:40 PM
deeyae
deeyae - avatar
+ 2
Vyoma, what is your question? It looks more like you're telling us something.
24th Jul 2019, 1:49 PM
HonFu
HonFu - avatar
+ 2
But if you tried it, then you already know the answer of your question, don't you? 🤔
24th Jul 2019, 2:02 PM
HonFu
HonFu - avatar
0
Well Dhanush Adithya I actually wanted to convey that only that whether we use array or any map functions multiplied with 0 will produce nothing as for array an empty array and likewise for other simple print function too
24th Jul 2019, 1:44 PM
Vyoma Patel
Vyoma Patel - avatar
0
Well Dhanush Adithya HonFu [#GoGetThatBugChamp!] Actually I asked question but took example written in description so that if I am wrong someone who reads it corrects my mistake I hope know both of you are clear
24th Jul 2019, 1:52 PM
Vyoma Patel
Vyoma Patel - avatar