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?
8 ответов
+ 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.
+ 2
My bad. Yes, you *do* need the int() funtion. :)
+ 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.
+ 1
Josiah if not specified, anything typed after the "input()" prompt will be a string. Even if it is a number
+ 1
Thank you guys!!!
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
- 2
File "/usercode/file0.py", line 7
elif BMI <=18.5 and < 25:
^
SyntaxError: invalid syntax
Please i need help guys
- 2
HELP ME GUYS!