+ 1
Can you help me, please? I'm a newbie, what's wrong with my program?
Name =input("Enter your name: ") Address =input("Enter your address: ") Age =input("Enter your age: ") Height =(float(input("Enter your height(m): ")*1000) print ("name : "+Name) print ("address : "+Address) print ("age : "+Age) print ("height : "+Height)
9 Answers
+ 3
The last line caused the error
print("Height : "+Height)
This is occurs when you try to add a float/integer to a string.
Solution, use
print("Height : ",Height)
OR
print("Height : "+ str(Height))
+ 4
You can use any one of these methods to print any non-string data type with your string
num = 21
print('hi', num)
print('hi {}'.format(num))
print(f'hi {num}')
+ 2
A few things.
You have a missing closing parenthesis on line 4 (after input):
Height =(float(input("Enter your height(m): "))*1000)
On the last line, you cannot concatenate float with string. Convert Height to string prior to doing so.
print ("height : "+str(Height))
+ 2
Mind To Machine đ»đ It can only concatenate strings, which is why you have to first convert any non-string value to string using str()
I personally prefer doing
print("Height : ",Height)
Instead of
print("Height : "+str(Height))
+ 2
Okay, thank you, buddies
+ 1
Thanks for your help, guys. But it's still not working, maybe you can try to run that programđ
0
Wat is m
0
You took and didnt use any where