#π whats wrong?
29 messages Β· Page 1 of 1 (latest)
@gaunt storm
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.
Have you learned about str and int yet?
thank u remembering that Im an idiot lol

worry not. i've been pythoning for a longer time and saw no problem. was about to ask if you forgot to save
It's the first thing I look for if I see input() being used
num = int(input("Enter your number?: "))
while num < 0 or num > 100:
print("invalid number")
num = int(input("Enter your number?: "))
print(f"your number is {num}")
Hey @gaunt storm!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
Traceback (most recent call last):
File "c:\Users\Admin\Desktop\Secret Code\first.py", line 1, in <module>
num = int(input("Enter your number?: "))
ValueError: invalid literal for int() with base 10: '23.4'
PS C:\Users\Admin\Desktop\Secret Code>
if you want 23.4 to work, then you need to convert to float, not int
can we make both
Why do you think you need both?
Int is integer, whole numbers. So you get the same error as if you entered "a" instead of a number
Float is decimal numbers (stored as floating point, hence the name "float")
All ints can be represented as decimals - just with 0 after the decimal point. So you don't need both
num = float(input("Enter your number?: "))
while num < 0 or num > 100:
print("invalid number")
num = int(input("Enter your number?: "))
print("Invalid number"if num == 23 else "Good")
Hey @gaunt storm!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
still error
you still have int around the 2nd input
you only changed the first one
always take a moment to look over your code
always look at the line number
I second the
always look at the line number
Python errors are quite good (since version 3.10, if I remember correctly) - so just read them and you'll soon be able to debug the stuff yourself.
Here: the error would be the same as original one (and now you already know what it means!), but showing the second input line -> so you'd see the line and notice it still has int
This help channel has been closed. 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.
