I am trying to make a tic-tac-toe game, and I currently have a 3×3 tiled board grid to represent the game. When a user clicks a square, the program sets board[x][y] to 1. board = [[[0, 0, 0], [0, 0, 0], [0, 0, 0]] Unfortunately, whenever I click a tile, it seems to ignore whatever x value I put; every
Tag: list
How can I pass a list from one class to another?
I’m still pretty new to python so, as said in the title, I’m trying to pass a list from inside one class to another class. For example: As shown in the example I want a list from class one to be passed to class two so that it can then be used (printed in the example). Answer You should make
how to get data from text file and rewrite to another from
hello beautiful people so i have a text file like this : user = user447 pass = 455555az type = registred date = 1 year and i want to read the file and rewrite it like this user|pass|type|date, line by line, i tried so many ways , i seem stuck since i have to deal with 1 million account Answer
Generating lists from other lists while keeping the order [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 11 months ago. Improve this question I have a list in the form of [2, 1, 4, 3]. Is there a way to produce all of the possible sequences of the
Python – Checking if the data in the files is the same
I have two lists where I have the same number of files. The files in both folders have the same names, for example: and so on. In the test2 folder I have the same named files. How can I compare for each file if the data in both files is the same? So whether: Are you able to advise something?
Changing specific elements in a list of list of numpy arrays
I have a list of lists of numpy arrays. I would like to loop through the list of lists and change certain elements. Below is an example, but just with integers: The i==j element has been changed to something else. When I run the exact same code logic, but with 2×2 numpy arrays, I cannot get it to do the
Pandas: add column name to a list, if the column contains a specific set of value
I wish to create a new list which contains column names of those columns which have atleast one of the following values. Most of the time Quite Often Less than often Never Sample : df ={‘A’:[‘name1’, ‘name2’, ‘name3’, ‘name4’], h_ls = [‘B’,’E’,’F’] I tried the following code I get an error that says ‘Timestamp’ object has no attribute ‘startswith’ It
How can I handle only the first part of my value list of a dictionary in Python?
I have a dictionary which has a list of values and I want to use only the first value of each pair before the first comma. Is that possible? If you came across anything similar please write it down Answer The output you expect is unclear. If you want a dictionary in which you only keep the first item of
Output of split is not what I was expecting
I’m just learning python, and I’m having some problems reading a .txt file that I created. My objective: I have a txt file with a list of strings. I’m trying to read, process it and save every letter into a new list. example2.txt file: [one, two, THREE, one, two, ten, eight,cat, dog, bird, fish] [Alonso, Alicia, Bob, Lynn] , [red,
Finding the headers for values in Json files
Hi I’ve got json data that looks something like this: I’m looking to convert this into lists that look something like this: So far I’ve been able to get all the names that I want using objectpath. But I’ve been unable to get the appropriate headers for each name as it appears to be nested under the ‘content’ header Any