#๐ Code Confusion
33 messages ยท Page 1 of 1 (latest)
@mossy orchid
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!code What do you have so far.
overall = input("What is your Overall Mark?: ")
print(overall)
if (overall == 1-100):
average = input("What was your Midterm Average? ")
print(average)
else:
print("Your Overall has to be between 0 - 100 ")
thank you i was trying to remember the format, this is my code.
if (overall == 1-100):
You dont need the brackets and the symbol - doesn't help you either. Its best you use < and > to check.
okay so i put down ```py
if overall = <=100 :
!e
input_list = [-5,0,5,60,100,150,350]
for i in input_list:
if 0 < i <= 100:
print(i)
else:
print(f"Invalid number used {i}")
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | Invalid number used -5
002 | Invalid number used 0
003 | 5
004 | 60
005 | 100
006 | Invalid number used 150
007 | Invalid number used 350
okay im not going to lie im still kind of confused ive only been coding for about two weeks.
What are you confused about?
im assuming this is what woud work for the input to only be betewwn 0-100 but i dont understand how this works
if 0 < i <= 100: do you understand what this line does?
no i do not.
But you got it done yourself here?
oh okay so the "i" is basically my "overall" and you added " 0 < " so it cant be below 100
Ahhh you got confused the the forloop. Best i can explain is that i can be anything that you want it to be. Like the overall varible.
TypeError: '<' not supported between instances of 'int' and 'str'
i keep getting this error though.
You cant compare intergers and strings.
When you get an input, the input will be a string by default you can change it to a interger by doing
overall = int(input("What is your Overall Mark?: ")). However this will throw a error is the user inputs anything that cant be converted to a number.
yeah when i changes it to that the same error message pops up even when i input a number
Show screenshot of the code and the error message
that was my only problem, thank you very much.
Thats good. do !close here to close the post.
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.