- 3
Please tell me what's wrong in this code.
when I run this code the analyser says, syntax error in line9 side1 = int(input()) side2 = int(input()) side3 = int(input()) side3>side1 side3>side2 side1**2=x side2**2=y side3**2=z if x+y=z: print("Right-angled") else: print("Not right-angled")
17 Réponses
+ 5
Samudra Saikia , yes sure - your code is for practice, but what is the purpose of this code? I assume it is to check if a triangle with 3 given sides is a right-angled triangle. So this information should be given when posting the question.
if so the code for it could be done like:
# input 3 values separated by space
# input of the 3 values will be splitted, converted to int and stored in a list inp
inp = [int(i) for i in input('values for a, b, c: ').split()]
if inp[0]**2 + inp[1]**2 == inp[2]**2:
print(True)
else:
print(False)
#or in a more compact form use this:
inp = [int(i) for i in input('values for a, b, c: ').split()]
print(True) if inp[0]**2 + inp[1]**2 == inp[2]**2 else False
+ 4
Samudra Saikia , can you please tell us, what you try to achieve with this code. Thanks!
+ 3
Oh try if x+y==z:
As far as i know = is the assignment operator and == is for comparison:)
If this still doesn't work you could try to store x+y in another variable and compare that with z :)
+ 2
Single '=' is an assignment operator, it cannot be used to compare two operator, Hence you should use '==' operator.
0
Maybe you're missing a space or tab?
0
I don't think so, what should I try to fix it
0
I can tell that there's no problem in those things, I tried it all. Its a problem with the if statement
0
its the same fixing problem here too
color = input()
if color=red:
print('1')
elif color=green:
print('2')
elif color=black:
print('3')
else:
print()
when I run it the analyser says invalid syntax line2
0
and in this one too
number = input()
if number%2=0:
print(number**2)
elif number%3=0
print(number**3)
else number=0
print("0")
invalid syntax line2
can anyone tell me what's wrong here
0
anyone please
0
https://code.sololearn.com/coKCfNdBXi31/?ref=app
Works just fine here.
0
Christian Hauck is right, same problem in the other two codes as same single '=' in them too.
0
that code was to practice
0
Christian Hauck thanks
0
If x+y=z has no items since they don't exist as variables.
0
color = input()
if color=='red':
print('1')
elif color=='green':
print('2')
elif color=='black':
print('3')
else:
print('4')
- 2
Hello