#π How can I fix this error?
32 messages Β· Page 1 of 1 (latest)
@silver hedge
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.
import string
cols = 15
rows = 15
print("Please input your point in a [()] bracket.")
points: str = input("Please input your point.")
for y in range(rows//2, -(rows//2) - 1, -1):
for x in range(-(cols//2), cols//2 + 1, 1):
currentPoint = (x,y)
if currentPoint in points:
print("X", end = "")
if currentPoint == (0, 0):
print("+", end = "")
if x == 0:
print ("|", end = "")
if y == 0:
print("-", end = "")
else:
print(" ", end= "")
print()
this is my current code
what do you tihnk that if statement is doing there?
wdym?
it makes the x appear where the point is i think
thats what happens if the statement is true
if the if statement checks in
its supposed to happen IF currentPoint is in points
if currentPoint in points:
what are you saying currentPoint is in the code?
where the point is placed
a string
but you specified it as a tuple: currentPoint = (x,y)
oh mb
you can't check if a tuple is in a string
now what you can do
is make the currentPoint a string with the format (x,y)
and you do that by formatting string
like this
currentPoint = f"({x},{y})"```
let me know if that works
oh thank you
nice
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.