#๐Ÿ”’ Code Confusion

33 messages ยท Page 1 of 1 (latest)

mossy orchid
#

i am trying to make an input message where you can only put in numbers between 0 and 100 but i cant quite get it right.

timber agateBOT
#

@mossy orchid

Python help channel opened

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.

timber agateBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

mossy orchid
#
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 ")

mossy orchid
main adder
mossy orchid
#

okay so i put down ```py
if overall = <=100 :

main adder
#

!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}")
timber agateBOT
mossy orchid
#

okay im not going to lie im still kind of confused ive only been coding for about two weeks.

mossy orchid
main adder
mossy orchid
#

no i do not.

main adder
mossy orchid
#

oh okay so the "i" is basically my "overall" and you added " 0 < " so it cant be below 100

main adder
mossy orchid
#

TypeError: '<' not supported between instances of 'int' and 'str'

#

i keep getting this error though.

main adder
#

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.

mossy orchid
#

yeah when i changes it to that the same error message pops up even when i input a number

main adder
mossy orchid
#

ohhh i missed the extra ")" at the end thats why

#

it works now.

main adder
#

Do you have any other questions?

mossy orchid
#

that was my only problem, thank you very much.

main adder
mossy orchid
#

!close

timber agateBOT
#
Python help channel closed

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.