#๐ unsupported operand help
27 messages ยท Page 1 of 1 (latest)
@long star
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.
sleep variable is a string
also provide code as text and not screenshot please
why are you making strings out of numbers?
you dont have to sleep = str(80)
just assign sleep to an integer: sleep = 80
theres a lot of usual conversion
if you get "unsupported operand type(s) for /: 'str' and 'int'", then the one on the left is a str and the one on the right is an int.
it looks like you're trying to change the type of the right operand, but the error message is telling you that the left operand is wrong.
sorry for my horrible explaining :P
this is so much better
this is what they pay me for. (even though I get paid in lemons.)
silly :3
i should try to feed noobies less
@long star do you understand?
left at in the sleep = sleep
why did you do sleep = str(80) at the start of your code?
that causes sleep to be a string, making it meaningless to divide by a number.
Traceback (most recent call last): File "E:\pythong\idk.py", line 13, in <module> print("your money is now at" +wallet) ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ TypeError: can only concatenate str (not "float") to str
error i have
try using an fstring
`import time
#money stuff
wallet = (540.25)
fast_food_price = (30)
work_check = (100)
#health stuff
hunger = (50)
sleep = (80)
print("good morning,")
print("your money is now at" +wallet)
print("your hunger is "+hunger)
print("your sleep is "+sleep)
time.sleep(1)
print("what would you like to do " )
time.sleep(1)
day_choice = input("sleep, go out to eat, go to work? " )
if day_choice == "sleep":
print("going to sleep, good night...")
time.sleep(5)
sleep = sleep / (50)
print("good morning, your sleep is now at" +sleep)`
!fstring
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
^
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.