Hey everyone.
So now we have also decided who is the winner.
Now we are going for deep play a move that is something going to be a little harder to understand but
I believe you will understand this one also because you will love you know other students.
So in player move before writing the call we need to understand something.
That is when we are getting that here.
If you notice let me have this one again here.
This one is asking please select a position to place an X.
So here first thing is I need to add any position that is from 1 2 9 that is going to buy my input but
if you remember that whenever we take any input like we have done before in numbers as it dropped then
that number will be taken in form of string.
So one thing before writing any code you need to remember that this string is taken as an input in Python
3.
So we need to convert this string into Indonesia.
Second thing is what if I am not me and you use it something other than 1 or 1 2 9 like he add something
like any alphabet or any number greater than nine then we need to make our program know that that thing
is invalid.
So that program will not show any error and it will show something as like Please enter a valid correct.
So we have to focus on
valid characters.
That is we have also done in hangman.
You remember that.
So we have to focus on these valued characters that either they are the third thing that is what if
I write something like you have to and I again write on that particular position then somebody before
writing me in the computer.
Vince let me again.
And that here came by like I have entered first.
Then I again to write on first then please select and in that position this one is occupied so that
one is also a case.
So we have to also focus on
focus on space.
Is it available or not.
So these are the three main things that we need to focus why they use it inputs any value.
And again we define a function that is player move that makes a sense I believe for player move we do
not divide any barometer that's because that is just we need an input that we take inside the function
because passing the parameter in that case that is a little difficult to convert that from one to another.
So we will take a variable that is one that will turn the code and that will be true in case in the
beginning then Day function get its first input.
So we will apply here Vilde run by layer that run is true.
So this is I have done you will understand when I write the complete code here.
So first of all I will take the input.
So here this values because I need to get input again and again.
So whenever that run will be true like whenever my Duncan then add that position this will become true
and I need to have input the value so input.
Something like please
select
position position to enter the
X
between 1 to 9 and then like that you can add any string like into this one we have a different one
but here I have written this one because that one is I have right before now do things like space and
all the things that we have to focus on now we will apply them but this time we are going to use something
as then if an LS That is a new thing you gotta to learn that is dry there are two statements you can
see this one and also double because it's a pre-defined one and except this one is also like if ls but
it has a proper use in some situations like the one that we are dealing with and this one is a homework
for you to understand these two network there.
Now first thing the input that I have taken so it will try to make the input first into the integer
value so we have in most because that one is a string as I have told you so trusting done that we have
done.
Second thing about the well it characters so the acting the also is due here.
But before that if move is greater than zero.
Like what if the user doesn't enter anything and
now this thing.
Well in addition to that it's range that will be less than
10.
So here you can also take this statement like between from zero to 10.
We have done this thing.
And second is a move and it's greater than zero.
Like I can add something like just empty and hit enter.
So I will get please type a number.
So the thing here the number must be greater than zero and less than nine.
And there must be something that like something cannot be void.
Now here if this thing is greater than zero and move less than 10.
So in that case we will make our loop stop because after our turn it will be computers done so run really
well to falls.
So that computer will get to know that.
Now his turn came and then we just insert the letter that is we use the insert letter function that
if the position is there then it will insert the value in that particular position.
So that's what we have we do not have to return any value because we just need to add that particular
value to that position.
So we will use that function here because now we require the insertion.
So insert that value and that value will be capital of X and then the next parameter that is our position
is move because if you notice the user enter the number and that number is not the value of a value
is X. We have only two values that is an X move is deportation.
So that's why we have converted this one into into value.
And then we have passed this bill barometer restive position because in insert letter we have two parameters.
I think you get this one that what I have done before.
So are we done here.
And after that as they will return something like print and this statement sorry
this space is occupied.
And for that we do not have another thing to return him just to do things like sort of the spaces occupied
and for that also.
Now if we want to add this we require a statement also here that is if space is free.
That is where this function for the particular position that is move then it will do this thing.
So command X this one and come on this one
forget to mention dysfunction here.
So this condition now.
This is done that if this space is free we have used these space free from space is free.
This one then it will insert the value on that particular position and if not then it will require the
space is free.
Now if the we are done with this free space now the valid collector.
Now if the character is valid then it will do this thing.
A device
is to ensure something like
print
please
type on number between 1 and 9 here.
Space until now.
Here.
This.
If you get back as now we have focus on the value the collector also string us.
Now we are done with this play and move completely.
Just this expect condition like when this drag out failed.
What to do in that case.
Print
This one happens when like something if I enter these things.
So here in that case I will write.
Please
type.
No.
So if the user doesn't enter the number then in that case this thing happens because on that point this
code shows error that they cannot convert the string type into.
So these conditions get full display in that case get in that case get filled.
So in that case this acceptable.
[REMOVED] that please type a number.
So if you go from the very inside of this code and this code also requires you to focus because you
get confused that at which position you have to enter what syntax like.
I also forget where Dave condition in the particular case here.
So first thing it will insert that particular reactor at the position move and done they run through
files so that it will be computer stuff and this thing only happens when there is a space free.
If the space is not free we will show an alert for spaces occupied.
Now this whole can only work when the number is in the valid range.
Please Dave I'm sorry.
When the number is valid range and if that is not we will surely alert like Please type a number between
1 and drain because that's over French.
And in case this whole try get failed when the user input like something integer type sorting string
develops in that case this doesn't convert that one into number and we get added.
So when this drag it filled the acceptable will work that will show print as please type a number.
The thing we have used try and accept instead of defendants because in effect as only you know the condition
is check like if I write a written here the if then if these conditions begin false that is it is not
able to convert that one so it will show error.
So try and expect something that shows the and that works on the values when the inner program will
work or not drag it failed when the inner program is show.
Otherwise it will work.
So that's about the player mood.
I hope you understand because this one is a little typical to understand.
You have to go from the inside and then try to understand coming outwards.
That's why it's a little hard to write this one from first here to going inside.
So thanks for watching.
And we're also done with the player move now and under more typical task writing the computer that we
are going to do in the next video.
So thanks for watching and we will continue in the next video.