0

String conversion

How do calculate total_owls when given num_owls_A is ‘3’ and num_owls_B is ‘4’ the output should be 7

8th Feb 2019, 3:45 AM
Safina Nganga
Safina Nganga - avatar
11 Antworten
+ 2
What language? If it's python then: num_owls_A = '3' num_owls_B= '4' print(int(num_owls_A)+int(num_owls_B))
8th Feb 2019, 4:04 AM
Lambda_Driver
Lambda_Driver - avatar
+ 2
My first answer will work. To understand what is happening, check this out: https://code.sololearn.com/ci4X0V5KR757/?ref=app
8th Feb 2019, 4:20 AM
Lambda_Driver
Lambda_Driver - avatar
+ 1
You could just save the result in another variable if you need to use the value later if you want.
8th Feb 2019, 4:26 AM
Lambda_Driver
Lambda_Driver - avatar
+ 1
total_owls=int(num_owls_A) + int(num_owls_B)
8th Feb 2019, 5:00 AM
Safina Nganga
Safina Nganga - avatar
0
but we’re told that the output should print the value of the total number of owls which is the sum of num_owls_A and num_owls_B
8th Feb 2019, 4:07 AM
Safina Nganga
Safina Nganga - avatar
0
it is in python
8th Feb 2019, 4:08 AM
Safina Nganga
Safina Nganga - avatar
0
im supposed to caluclate the total number of owls with those strings not print them
8th Feb 2019, 4:22 AM
Safina Nganga
Safina Nganga - avatar
0
alright
8th Feb 2019, 4:24 AM
Safina Nganga
Safina Nganga - avatar
0
but theyre both strings😭😭😭😭
8th Feb 2019, 4:25 AM
Safina Nganga
Safina Nganga - avatar
0
i get what you You mean but it’s just a challenge activity that we have to do for our python class so it’s just telling us to find the total number of always using the strings that I gave you saw the three in the form which are placed in the variables That I gave respectively
8th Feb 2019, 4:33 AM
Safina Nganga
Safina Nganga - avatar
0
i got it thanks
8th Feb 2019, 4:59 AM
Safina Nganga
Safina Nganga - avatar