+ 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)

24th Jul 2019, 1:27 AM
Captain
Captain - avatar
9 odpowiedzi
+ 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))
24th Jul 2019, 1:49 AM
Dlite
Dlite - avatar
+ 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}')
24th Jul 2019, 2:34 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 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))
24th Jul 2019, 1:50 AM
Fermi
Fermi - avatar
+ 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))
24th Jul 2019, 11:57 PM
Dlite
Dlite - avatar
+ 2
Okay, thank you, buddies
25th Jul 2019, 12:17 AM
Captain
Captain - avatar
+ 1
Thanks for your help, guys. But it's still not working, maybe you can try to run that program😅
24th Jul 2019, 1:57 AM
Captain
Captain - avatar
+ 1
D'Lite so the + operator in a lang like PYTHON does not have a concat overload 🤔
24th Jul 2019, 4:01 AM
Mind To Machine 💻🕆
Mind To Machine 💻🕆 - avatar
0
Wat is m
28th Jul 2019, 5:22 AM
Tanu deep
0
You took and didnt use any where
28th Jul 2019, 5:25 AM
Tanu deep