I can't understand how this code works. Please explain about the output it gives


#1


#2

This code is confusing. input() will store the result as string, given what its suppose to do, isn’t it better to convert to integer?

This code/function also has a recursion problem, it has recursion but no base case, so the recursion will go until it reaches it maximum depth. Which is sort of like an infinity loop, you don’t want this, do you?


#3

nope.actually i was trying to figure out the code to print multiplication table of a given number…but i found the way to print numbers one by one (if “num” is not present it prints numbers one by one) so i tried to multiply the output with the input we give so i inserted “num” but the output was like

this…donno how i got dis as output …in need of explaination


#4

thank u by the way after changing “input” with “int(input” it prints the mutliples of the given number thank u so much


#5

string multiplication is weird:

print("hello" * 5) # will output hellohellohellohellohello

that is why the output was weird


#6

understood…thank u so much :slight_smile: