pythonjupyter-notebookjupyterjupyter-labjupyter-irkernel

how to get the product after the colons


so im learning this program BMI calculator, and i want the answers to be written after the ':', not under it. can anyone help me pls? is it even possible to get that type of answer?

heres the code:

name = "hello"
height_m = 2
weight_kg = 110

bmi = weight_kg / (height_m ** 2)
print("bmi:")
print(bmi)
if bmi < 25:
    print(name)
    print("is not overweight")
else:
    print(name)
    print("is overweight")

#printed:
bmi:
27.5
hello
is overweight

#but what i want is this:
bmi: 27.5
hello is overweight

Solution

  • You need to put a comma in the same print statement instead of two separate ones.

    print("bmi:",bmi)
    

    instead of

    print("bmi:")
    print(bmi)