#๐Ÿ”’ is it possible to stack is on top of each other?

32 messages ยท Page 1 of 1 (latest)

hearty coralBOT
#

Hey @violet nebula!

It looks like you are trying to paste code into this channel.

You seem to be using the wrong symbols to indicate where the code block should start. The correct symbols would be ```, not '''.

Furthermore, it looks like you pasted Python code without syntax highlighting. Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
#

@violet nebula

Python help channel opened

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.

violet nebula
#

def connect_four(the_grid, player_symbol):
    grid = []
    for x in range(the_grid):
        rows = input(">> ").strip()
        grid.append(rows)

        
    return grid








if __name__ == '__main__':
    rows = int(input("How many rows do you want? "))
    player_symbol = input("what will be your symbol? ")
    result = connect_four(rows, player_symbol)
    print(result, end= ",")

#

does anyone if its possible to make a list like this?

#

[x,x,x,x]
[x,x,x,x]
[x,x,x,x]
[x,x,x,x]

#

which is also in another list

boreal wigeon
#

!e An easy to understand way to make one would be: ```py
dims = 4 # you can take input for dimensions
grid = []
for i in range(dims):
grid.append([])
for j in range(dims):
grid[i].append(0) # I'm using 0 as a default value

print(grid)

hearty coralBOT
boreal wigeon
#

!e a more advanced way would be ```py
dims = 4
grid = [[0 for _ in range(dims)] for _ in range(dims)]

print(grid)

hearty coralBOT
violet nebula
#

ik how to do that im asking if its possible for that in the list to looked like its stacked

boreal wigeon
#

ohh

#

mb

#

yes

#

!e an easy way:

lis = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
for sublis in lis:
    print(sublis)
hearty coralBOT
boreal wigeon
#

!e a more advanced way: ```py
lis = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
print(*lis, sep='\n')

hearty coralBOT
violet nebula
#

so you can output a list like that

#

rather then storing it?

boreal wigeon
#

wdym

violet nebula
#

like if i wanted
var = [x,x,x,x]
[x,x,x,x]
[x,x,x,x]

#

that wouldnt be possible would it?

boreal wigeon
#

idk why you would want that

#

but it's kinda possible

#
lis = [
  [0, 0, 0, 0],
  [0, 0, 0, 0],
  [0, 0, 0, 0],
  [0, 0, 0, 0]
]
violet nebula
#

but that would just look flat in the variables right?

boreal wigeon
#

how you write it in ur code doesnt affect how the program interprets it so yes when you print it out it would be flat

violet nebula
#

okay then

hearty coralBOT
#
Python help channel closed

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.