please answer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4th Apr 2018, 6:10 AM
Pirate - avatar
2 Answers
+ 10
When you multiply a string by a number you get repetitions, e.g., so print("Ha" * 3) gives HaHaHa. The input() function always outputs a string, so if you want an integer (or float), use 「HAPPY TO HELP」 's suggestion, i.e. int(input()) or float(input())
4th Apr 2018, 8:00 AM
David Ashton
David Ashton - avatar
+ 1
Don't forget that input() stores everything in string by default. Thus your '5', when multiplied by 5 goes as '5'*5 ('5' + '5' + '5' . . . ) And, actually, I am to be considered new to coding myself, but your tags are kind of an abuse. SoloLearn's first chapter covers all of the questions of yours, as well as data types and how one works with another. Check Python Tutorial: Basic Concepts - String Operations (3/3)
4th Apr 2018, 7:51 AM
Andrey Vostokov
Andrey Vostokov - avatar