/usercode/file0.py error | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

/usercode/file0.py error

Can someone explain this? In this code it's linked to a traceback error, but I see it in all of my other code? I'm trying to do the hovercraft lesson and I have cost_boat = int(2000000) ins = int(1000000) x = input("") total_cost = ins + (cost_boat * 10) revenue = int(3000000) * x if revenue > total_cost: print("Profit") elif revenue < total_cost: print("Loss") elif revenue == total_cost: print("Broke Even") The code throws in line 7 but what is wrong?

7th May 2020, 12:31 AM
Aaron Wilkinson
8 Respuestas
+ 2
probably because x is a string and 3000000 is an interger. When you assigned revenue a value you attempted to multiply an integer by a string and that wont work.
7th May 2020, 12:52 AM
Slick
Slick - avatar
+ 2
My bad. Yes, you *do* need the int() funtion. :)
7th May 2020, 2:16 AM
Runcible
+ 1
Try changing line 3 to: x = int(input()) You technically dont need the int() function, since the exercise is going to give an integer as input, but you dont want the value to be a string.
7th May 2020, 2:03 AM
Runcible
+ 1
Josiah if not specified, anything typed after the "input()" prompt will be a string. Even if it is a number
7th May 2020, 2:06 AM
Slick
Slick - avatar
+ 1
Thank you guys!!!
7th May 2020, 7:24 PM
Aaron Wilkinson
0
from OpenGL.GLUT import * from OpenGL.GL import * def draw(): # Clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Set the color to red glColor3f(1.0, 0.0, 0.0) # Draw the cube glutWireCube(1.0) # Flush the image to the screen glFlush() # Initialize the OpenGL context glutInit() # Set the display mode glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH) # Set the initial window position and size glutInitWindowPosition(50, 50) glutInitWindowSize(500, 500) # Create the window glutCreateWindow("Moving Cube") # Set the background color to black glClearColor(0.0, 0.0, 0.0, 0.0) # Set the perspective glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(-1.5, 1.5, -1.5, 1.5, -1.5, 1.5) # Set the viewing direction glMatrixMode(GL_MODEL
12th Dec 2022, 1:12 PM
Ayoun Elghazali
Ayoun Elghazali - avatar
- 2
File "/usercode/file0.py", line 7 elif BMI <=18.5 and < 25: ^ SyntaxError: invalid syntax Please i need help guys
17th Aug 2021, 8:32 PM
Julius Mcbraham Paapa-Boateng Somuah
Julius Mcbraham Paapa-Boateng Somuah - avatar
- 2
HELP ME GUYS!
5th May 2022, 8:43 AM
ELENA