So I want to create 4 function: func_slideright()
func_slideleft()
func_up()
and func_left()
that will find and print all words from a grid like this.
[["r","a","w","b","i","t"],
["x","a","y","z","c","h"],
["p","q","b","e","i","e"],
["t","r","s","b","o","g"],
["u","w","x","v","i","t"],
["n","m","r","w","o","t"]]
so basically... func_slideright()
will return every letter in the grid horizontally from left to right.. so the output should look like this.
n
um
twr
prxw
xqsvo
and so on...
while func_slideleft()
will print out the opposite of sliderright, so like...
t
ih
bce
wzig
and so on.... while func_up() will return letters from top to bottom like
rxptun
aaqrwm
wybsxr
and so on... and func_left() returns all letters from left to right like
rawbit
xayczh
and so on...
Also word: str
is basically the word that I'm trying to find whether it's there on the grid or not.
However, I'm completely stuck on how to do this. No piece of code or program seems to click in my mind for some reason, so can anyone please help?? ** Also if u do generously help me, please consider writing in the simplest way possible and please an explaination as well so that I can learn and not ask repeated questions on here. Thank you :))**
Here is my code so far. Any help would be appreciated...
grid = [["r","a","w","b","i","t"],
["x","a","y","z","c","h"],
["p","q","b","e","i","e"],
["t","r","s","b","o","g"],
["u","w","x","v","i","t"],
["n","m","r","w","o","t"]]
def func_left(word, grid):
word = list(word)
for x in grid:
if grid.index(word[x]) != 1:
return word
print(func_left(word='raw', grid=[["r","a","w","b","i","t"],
["x","a","y","z","c","h"],
["p","q","b","e","i","e"],
["t","r","s","b","o","g"],
["u","w","x","v","i","t"],
["n","m","r","w","o","t"]]))
def func_slideleft(word, grid):
word = list(word)
** I have no idea how to find this or how to find sliderright
def func_sliderright(word, grid):
word = list(word)
** I have no idea how to find this or how to find sliderright
def func_up(word):
word = list(word)
for x in grid:
return x[1]