Issue
I was making a code to find the number divisible by x in a certain range and for that this is the code I wrote:
num = int(input("Enter your number: "))
for i in range(1,301):
if i % num == 0:
print(i)
I was able to get the result, however then I wanted to get the final print in this format:
13 / 13 = 1
26 / 13 = 2
and so on for any number chosen by the user. Please guide me how to get the result that way.
Solution
Can you try this:
num = int(input("Enter your number: "))
for i in range(1,301):
if i % num == 0:
print(f"{i} / {num} = {int(i/num)}")
Answered By - White Hat Hacker
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.