#🔒 what can I do? quick question
23 messages · Page 1 of 1 (latest)
@clear surge
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.
Here’s an example of what I mean by a block of integers
2 4 1 3 4 3 2 1 1 3 2 4 4 1 3 2 3 4 2 1 2 4 3 1 3 2 1 4 2 3 1 4 3 2 4 1 3 2 1 4 3 2 4 3 1 2 4 1 3 2 1 4 3 1 4 2 3 2 1 4 3 2 4 1 3 1 2 3 4 1 4 2 3 3 4 2 1 4 1 3 2 2 4 3 1 1 2 3 4 4 3 1 2 3 2 1 4 1 3 2
So for example I want my code to check each digit
Each digit has a corresponding action
i'd suggest putting them in a text file and then reading and parsing the file
Parsing?
general term for transforming an input into something you can use
are you familiar with opening files with python?
No
with open("path/to/myfile.txt") as file:
for line in file: # line is a string representing each line in the file
numbers = line.split() # splitting that string by spaces into a list of the numbers (as strings)
the path to the file is relative to your current working directory
Then I can turn the strings into int?
If all you need to do is correspond a value to some sort of action, then it doesn't necessarily need to be int
unless you're using them to index a list of actions
but yes, you could if you really need to
I mean like I want to set a value = 0 then depending on the number either 2, 4 would do west and east so it’s coordinates would change
So I want my program to check every number so it can assign the new position
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.