Bringing things together - Iterators/Iterables - Python 3 Programming Tutorial p.13

preview_player
Показать описание
Welcome to part 13 of the Python 3 basics tutorial series. Here, we're going to be bringing our TicTacToe game together, so let's just get started.

#python #programming #tutorial
Рекомендации по теме
Комментарии
Автор

Fun fact - 'iter' is Latin for a 'walk', 'path', or 'journey'. An 'iterator' is someone/thing that actively takes steps along a path (just as a 'victor' is someone who wins), whereas a path (or in this case, a list, etc.) is 'iterable' because it can be followed but doesn't necessitate that stepwise movement (same as when you 'reiterate' something you return to the beginning and walk through it again). Anyway, great stuff, I appreciate your lack of smoke and mirrors!

EDIT: Some parallels might be "terminator" vs. "terminable" or "negotiator" vs. "negotiable"

Pkotiu
Автор

This was by far one of the hardest videos of your to watch,

gabriellachitamu
Автор

I <3 your collection of coffee cups!

blzfrost
Автор

This tutorial was really helpful for me, a rusty semi-beginner. I managed to modify this into a working Connect Four game which I recommend to anyone who wants some extra challenge!

ac-mlgd
Автор

anyone notice how every time he has a different mug lol

memegod
Автор

sentdex  I LOVED this video!! Laughed when you called me out for hating on the trailing comma hahahahaha
These tutorials are so wonderful because we're learning bits and pieces as we need them on a project that isn't too scary and intimidating. I'm excited to see why you keep putting an 'f' before the string in your prints.
Thank you for all your hard work.

Also, would you consider making a sudoku solver in python (done in a similar fashion to this series)? I ask because I made one as my first program and it seems to work, but it's slow as hell and I'd love to see how a skilled person such as yourself would tackle the task. Would you please consider this as a request, and then consider my request ;p

lank_asif
Автор

For revolving the player number I went with:


players = [1, 2]
while not game_won:
current_player = player[0]
players.reverse()




Obviously it falls apart if we want to try three player tic-tac-toe. :)

grepme
Автор

For me, I think a great way to toggle between player one and two is like this, "player = (player - 2) * -1 + 1".

anubis
Автор

i"m just a beginner in programing trying to learn python but i come up with neat way to switch players i just enter this 2 line inside the main loop:
active_player = (i % 2) + 1
i += 1

and that's it. you got your players rotation :-)

Yoshiko_ESK
Автор

13:33 okay so at this part the player can play the game! Cool but how is it working??Like what part of the code allows to print "1" given the column choice and row choice. Sorry about the noob question

ahmedanwer
Автор

got the notification that the premiere starts 2 minutes after it ended, let's go!

loukask.
Автор

Great explanation about de difference between iterator and iterable

rubempacelli
Автор

Is the any additional help on building knowledge on python I feel I am not getting a grasp

SMARTERSECS
Автор

players = [1, 2]
for i in range(10):

eastwoodsamuel
Автор

Hi! Ig u didn't include how to define if it's a draw....I have been trying check for draw but I can't pls tell how to define a draw or tie

invinciblegamer
Автор

Is there an advantage when you use itertools instead of just loop through a list players = [1, 2]?

while not game_won:
for current_player in players:
column_choice = input(f"Player {current_player}: What column do you want to play? (0, 1, 2) ")
row_choice = input(f"Player {current_player}: What row do you want to play? (0, 1, 2) ")

game_board(game, player=current_player, row=int(row_choice), column=int(column_choice))
game_won = win(game) # win() function checks for every way to win tic tac toe

if game_won:
break

tobias
Автор

that was a complicated way to go from player 1 to 2...
while play:
for player in (1, 2):
"play the game"

maybe your point was to introduce us to itertools tho ;)
And it also avoids overusing 'break' statement...

MrBoubource
Автор

I did a small implementation for cycling in a list of two elements :
l = [0, 1]

for idx in range(10):
l2 = l[-1:-(len(l) + 1): -1]
print(l2[0])
l3 = l2[-1:-(len(l) + 1):-1]
print(l3[0])

MiledRizk
Автор

I may be missing the point but to get the [1212121212...] sequence, can you not just put in a counter (let's call it c) that increments with each repetition of the while loop and then use player=1+(c%2) rather than itertools?

atrumluminarium
Автор

why is this code not working on pycharm? I had to use CMD where it works perfectly. What is the reason? (12:34)

findiariesteam