Skip to content
Sign upLog in
← Back to Community
i got the first 2 tasks done, i need help on the third.
Profile icon
Dominicl645

here is the third task...at first glance it seems simple. to me it is actually difficult and someone please help. any help is appreciated. thanks in advance.

i tried to have my variables num1 and num2 get added together, the print statement looked like this: print(num1 + num2), and the answer it gave me is just putting num1 in front of num2. i entered 6 for num1 and 9 for num2, when it gave me my answer it claims that 6 + 9 = 69. what the heck? last time i checked, 6 + 9 = 15.

@Coder100

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
SavageSpray
Profile icon
AnimeLover1069
Profile icon
cookieartist350
Profile icon
Dominicl645
Comments
hotnewtop
Profile icon
Coder100

Oh, on line 24 right?
The thing is you forgot to convert it into a int so it was still a string and concatenated the strings.
Here's the correct code:

if num1.isdigit() and num2.isdigit(): print(int(num1) + int(num2)) elif num1.isalpha() and num2.isalpha(): print("You did not enter a valid number") elif num1.isdigit() and num2.isalpha(): print("You entered only one valid number") elif num1.isalpha() and num2.isdigit(): print("You entered only one valid number") else: print("Do you even know what a number is? ")
Profile icon
Dominicl645

thanks. see i had most of it correct. yay you rock.

@Coder100

Profile icon
Coder100

yay thanks! :)

@dominicl645

Profile icon
Dominicl645

np. now i gotta figure out how to get more upvotes lol.

@Coder100

Profile icon
Coder100

@dominicl645
lol what

Profile icon
Dominicl645

trying to figure out how to get more upvotes.

@Coder100

Profile icon
Coder100

what help do you need

Profile icon
Dominicl645

i just updated it. i have to get num1 to add itself to num2.

@Coder100

Profile icon
Coder100

coolio check out my solution

@dominicl645

Profile icon
loyedneuer

I appreciate you sharing your expertise and experience. Your website is really good. five nights at freddy's The amount of knowledge on your website is astounding.

Profile icon
Dominicl645

any help will be greatly appreciated.