joelle joelle - 1 month ago 15
Python Question

Python basic result format

def meter_to_cm(m):
cm = m * 10
print(m,'m equals to',cm,'cm')

meter_to_cm(12)


The result shows

(12, 'm equals to', 120, 'cm')


How can I make it do not show the parentheses, quotes and commas?

Answer

For Python 3, use following

def meter_to_cm(m):
    cm = m * 100
    print("{0} m equals to {1} cm".format(m, cm))

meter_to_cm(12)
Comments