As most of the people answered already you need to convert string to desired output. So basically the input function takes any input as str
. We should convert it to desired data type.
Another issue is for the percentage calculation you have used //
which is floor division it will always round down the results causing your output always to be 0
.(https://www.w3schools.com/python/trypython.asp?filename=demo_oper_floordiv)
One last point is if you are using python2 or python3. In python3 using simple division(/
) will work fine with integers. But in python2 it will work like a //
if both denominator and numerator are of type (int). Hence you might not get desired results.
Below code should work fine for both python2 and python3. Because instead of converting input to int
we will be converting it to float
. Which will work with /
properly in both python2 and python3.
Women = float(input("What's the number of women?"))
Men = float(input("What's the number of men?"))
print("Percentage of Men: ", (Men / (Men + Women)) * 100)
print("Percentage of Women: ", (Women / (Men + Women)) * 100)