+ 1

Help!

Given a number, I want to check if it is divisible for 3. IF I don't get an integer number I have to add n in order to get (number%3==0). How can I do that?thanks

11th Feb 2021, 9:37 PM
The Rocky
The Rocky - avatar
7 ответов
+ 4
The Rocky number % 3 will return the remainder of division. So, it will return the value needed to add to the number in order to get number % 3 == 0 to be True. if number % 3 == 0: ... ... # number is divisible by 3 else: # number not divisible by 3 number += number % 3 # now number is divisible by 3 You could also set the remainder to a variable number = int(input()) rem = number % 3 print(f"Adding {rem} to {number} makes it evenly divisible by 3")
12th Feb 2021, 1:49 AM
ChaoticDawg
ChaoticDawg - avatar
+ 13
The Rocky read the guidelines of the community first. https://www.sololearn.com/discuss/1316935/?ref=app
11th Feb 2021, 10:11 PM
Ded
+ 11
please don't ask any homework question here :) show ur attempt first.
11th Feb 2021, 10:01 PM
Ded
+ 3
You are kidding me right? Your intervention is useless
11th Feb 2021, 10:08 PM
The Rocky
The Rocky - avatar
+ 3
So what... What is missing? If u know how to help me that is fine otherwise you are wasting my time
11th Feb 2021, 10:13 PM
The Rocky
The Rocky - avatar
+ 3
You are crazy... I just told you that I don't know how to do that!! I was thinking to increase the number by 1 in a while function that is all...
11th Feb 2021, 10:16 PM
The Rocky
The Rocky - avatar
+ 2
The Rocky The Tαrα°°☆ is correct first show your attempt if you have completed sololearn conditional statements lesson than you should do yourself if you have anything bug or problem in your code then tell us we wil help you
12th Feb 2021, 2:49 AM
Anurag Kumar
Anurag Kumar - avatar