Jul-07-2021, 05:14 PM
(This post was last modified: Jul-07-2021, 09:33 PM by deanhystad.)
You can multiply a string by an int. This makes the string repeat. When you multiply '3'x3 you get '3''3''3' or '333'. If you multiply that by 3 again you get '333''333''333' or '333333333'. This happens in your code because of a misplaced parenthesis.
print(int(num * int(num) * int(num))) # should be print(int(num) * int(num) * int(num))As has been mentioned, the time for the conversion is before you call the function. Not only does this make the function more useful, but you only need to perform the conversion once.