Im new to python and I've been given the task to code a centimetres to inches and vice versa program. The idea is a user enters a number, the program asks if they want to convert it from inches to centimetres or centimetres to inches and then displays the result.
Im using python 3.3.5 on a mac is that helps.
Here is my code: ( the commented out section shows the task and my first attempt)
##
##Write a program that converts between centimetres, and inches and vice versa, by:
##asking the user to input a number
##asking the user to choose between converting from centimetres to inches or from inches to centimetres
##calculating and outputting the result using functions
##### Old attempt
##print(" Program to convert beteween centimetres and inches " )
##
##centimetre = 1
##inch = centimetre * 2.45
##
##number = input (" Please enter a number: ")
##choice = input (" Do you want to convert into centimetres or inches: ")
##if choice == "centimetres" or "Centimetres":
## print("Your number is", centimetre*number, "cm")
##else:
## print("Your number is",number*inch, "inches")
number = int(input(" Please enter a number: "))
choice = input(str(" If you want to convert from centimetres to inches type 'A' \n If you want to convert from inches to centimetres type 'B': "))
if choice in "A" or "a":
print(" Your number is" , number*2.54,"inches")
else:
print(" Your number is", number/2.54, "centimetres")
Answer has been found, thank you for the very quick replies!