# Hey I need help on how to divide user inputed numbers

how to divide user inputted numbers

Hey @AnthonyPetrillo! Welcome to the communityâ€¦

Could you please link your repl, or elaborate more, maybe send some screenshots so we can better assistt you?

Thanks!!

The reason is because the numbers you are attempting to divide are not integers or floats. Use this code:

``````name = int(input("Please enter your name: "))
integer = int(input(name+ ", Please enter an integer: "))
integer2 = int(input(name+ ", Please enter another integer: "))
if integer % integer2 == 0:
print (f"{integer} is divisble by {integer2}")
else:
print (f"{integer} is NOT divisble by {integer2}")
``````

In what programming language?

In C++

``````#include <iostream>

int main(){
int one, two, a;
std::cin >> one;
std::cin >> two;
a = one/two;
std::cout << a;
}
``````
2 Likes

Oh, I found a repl on their profile in python and edited their code, I didnâ€™t realize it could be something else XD

smart lol, didnâ€™t think of that.

1 Like

Oh alright.

1 Like

No, no, youâ€™re right I may have found the wrong profile

Why is the name an int? Also, you should use mod (`%`) to check if it is evenly divisible.

I did not write the code, I merely fixed it to run without errors

Greetings @JaceBillingsley. I looked at your profile and noted that you joined just two days ago. I hope you have a good time in the olâ€™ community.

yes but remember to ping @sonicx180

1 Like

It gives me an error when I run it.
It should be this:

``````name = input("Please enter your name: ")
integer = int(input(name+ ", Please enter an integer: "))
integer2 = int(input(name+ ", Please enter another integer: "))
print (str(integer) + " is divisble by " + str(integer2))
else:
print (str(integer) + " is NOT divisble by " + str(integer2))
``````
2 Likes

code:

``````name = input("Please enter your name: ")
integer = int(input(name + ", Please enter an integer: "))
integer2 = int(input(name + ", Please enter another integer: "))
if integer % integer2 == 0:
print(f"{str(integer)} is divisible by {str(integer2)}")
else:
print(f"{str(integer)} is not divisible by {str(integer2)}")
``````
2 Likes

Mine and your code should both work.

2 Likes

it works for me sooo

1 Like

hey there for f-strings you donâ€™t need to change the typing @Sky

if you notice I edited mine before functionallyâ€™s to incorporate this

EDIT: did you get the â€ś@â€ť ping @Sky?

2 Likes

Think you pinged the wrong person.

1 Like

oops, does editing it change the ping?

hmmm I didnâ€™t get an @â€¦