1
00:00:00,720 --> 00:00:07,290
OK, so in this lecture, we are going to go over a different way to get user input.

2
00:00:07,710 --> 00:00:12,020
So you might be wondering, well, why would we need a different way?

3
00:00:12,090 --> 00:00:14,280
It seems like CNN is working fine for us.

4
00:00:14,700 --> 00:00:21,660
And yes, the works great for a lot of cases, but there are some edge cases where scene does not work

5
00:00:21,660 --> 00:00:22,140
so great.

6
00:00:22,410 --> 00:00:26,070
And that's what we're going to discuss today in this lecture.

7
00:00:26,760 --> 00:00:33,090
So these specific educations will involve us using something called get line.

8
00:00:33,390 --> 00:00:35,340
And another thing called Get.

9
00:00:38,430 --> 00:00:45,630
So a good example of what might lead us to use these sort of things is what if we wanted to read in

10
00:00:45,630 --> 00:00:47,010
someone's full name?

11
00:00:48,120 --> 00:00:54,450
So this would involve us reading into a string and reading into a string is something that I've hinted

12
00:00:54,450 --> 00:00:56,700
at in previous lectures, but I have not done yet.

13
00:00:56,710 --> 00:01:01,770
So let's go ahead and jump over to the editor and we will go ahead and go over that.

14
00:01:04,330 --> 00:01:04,750
So.

15
00:01:05,900 --> 00:01:11,210
I'm here in the ED. I have a little program that I've written, and I've actually already compiled it.

16
00:01:11,840 --> 00:01:14,660
I have a string here that's called input.

17
00:01:14,960 --> 00:01:16,970
So I declare variable string variable.

18
00:01:17,630 --> 00:01:21,680
Then I have this little message that says, Enter your name.

19
00:01:22,490 --> 00:01:26,900
Then I'm using scene to read into the string.

20
00:01:27,500 --> 00:01:28,930
And then I just print the string out.

21
00:01:28,940 --> 00:01:32,810
So it's just a program that tells someone to enter their name and spits it back out at them.

22
00:01:34,190 --> 00:01:35,930
So renew a string is kind of cool.

23
00:01:35,960 --> 00:01:37,310
We haven't really done that yet, right?

24
00:01:37,330 --> 00:01:41,540
We've only read into characters and integers and floats and stuff like that.

25
00:01:41,660 --> 00:01:48,470
But you actually can read into strings as well, because the string data Typekit someone created a bunch

26
00:01:48,470 --> 00:01:50,630
of code for this and they made it nice.

27
00:01:50,630 --> 00:01:57,140
So you can use this operator with this string type, the string variable.

28
00:01:58,490 --> 00:02:00,440
So let's go ahead and throw with this.

29
00:02:00,440 --> 00:02:01,910
I've already called this program.

30
00:02:03,890 --> 00:02:12,080
I did see I'm going to go ahead and run it, and I'm just going to type one and type a first name right

31
00:02:12,080 --> 00:02:12,410
now.

32
00:02:13,430 --> 00:02:16,910
So I type the first name and it just spit it out back at me.

33
00:02:16,910 --> 00:02:19,490
So you know that it read it in successfully.

34
00:02:20,890 --> 00:02:27,880
So what if I want to put it first and last name this, I knew Dylan and whatever program we had, last

35
00:02:27,880 --> 00:02:28,450
name, right?

36
00:02:30,550 --> 00:02:30,910
Huh.

37
00:02:30,940 --> 00:02:31,660
That's weird.

38
00:02:31,810 --> 00:02:36,130
It actually still just spit out only my first name.

39
00:02:37,130 --> 00:02:40,650
So that's a little weird.

40
00:02:40,670 --> 00:02:41,900
Why did it do that?

41
00:02:42,170 --> 00:02:49,040
Well, the reason that it did that is because CNN went into reading into a string.

42
00:02:49,340 --> 00:02:52,250
It actually only reads up.

43
00:02:52,250 --> 00:03:01,870
Intel encounters something called a white space character, which is a space or a new line or a tab.

44
00:03:01,880 --> 00:03:08,000
Anything that's like blank space that you could press on the keyboard, which would be Space Bar tab

45
00:03:08,330 --> 00:03:11,570
enter key creates a new line that stuff.

46
00:03:11,600 --> 00:03:20,000
Those are considered white space characters, and so the scene is only going to read up until it encounters

47
00:03:20,000 --> 00:03:21,860
a white space character.

48
00:03:22,880 --> 00:03:23,930
And we don't want that right.

49
00:03:23,940 --> 00:03:26,900
We want to grab this whole thing, the whole name.

50
00:03:27,770 --> 00:03:29,420
So how can we do that?

51
00:03:29,960 --> 00:03:35,600
Well, I will explain that on this slide, we're going to use something called the get line function.

52
00:03:38,220 --> 00:03:44,690
So to fix the problem, we can use something called the get line function, and yes, this is me introducing

53
00:03:44,700 --> 00:03:49,260
yet another function before explaining how to make functions.

54
00:03:49,290 --> 00:03:54,780
We're very close to that, but I still need to introduce some more functions that you can just use before

55
00:03:54,780 --> 00:03:55,500
making your own.

56
00:03:56,340 --> 00:04:02,100
So the get line function is kind of similar to like doing the dot length function, except you're not

57
00:04:02,100 --> 00:04:03,610
going to use a dot before it.

58
00:04:03,630 --> 00:04:06,900
All you have to do is put get line and then the parentheses.

59
00:04:07,290 --> 00:04:11,460
And what we're going to actually do is put stuff inside of the parentheses.

60
00:04:12,060 --> 00:04:17,850
So we were interested in calling the dot length on a string variable, right?

61
00:04:18,630 --> 00:04:24,570
If you're thinking about it in terms of like using the function with something like with the string

62
00:04:24,570 --> 00:04:29,340
variable, this time what we're going to do is actually put the things we're interested in using get

63
00:04:29,340 --> 00:04:32,310
line on inside these parentheses.

64
00:04:33,240 --> 00:04:35,510
So those things are going to be separated by comma.

65
00:04:35,520 --> 00:04:37,590
The first thing will be the C and object.

66
00:04:37,950 --> 00:04:39,270
So you put it right here.

67
00:04:40,600 --> 00:04:46,450
And the second thing after the comma is just going to be the variable that you want to read into.

68
00:04:47,320 --> 00:04:52,300
So when we have seen we were reading it into that input string, right?

69
00:04:52,930 --> 00:04:57,670
So all we're going to do now is just put C in and a comma and then put the input.

70
00:04:57,670 --> 00:05:04,990
And that will be like the same thing as reading through the stream coming from console in into our input

71
00:05:05,200 --> 00:05:06,670
variable or string variable.

72
00:05:07,270 --> 00:05:16,660
But instead of just doing that scene greater than greater than or, yeah, greater than greater than

73
00:05:16,660 --> 00:05:23,770
and the variable, then we're doing we're actually doing a function get line and then parentheses and

74
00:05:23,770 --> 00:05:25,570
putting the things of interest inside here.

75
00:05:28,410 --> 00:05:36,330
So how does it work, though, so let's take an example here, so this up here is what the keyboard

76
00:05:36,330 --> 00:05:37,590
buffer looks like.

77
00:05:38,760 --> 00:05:44,550
When I enter this example, this example input, so you notice we use get line here.

78
00:05:45,210 --> 00:05:47,850
I do a scene and the input.

79
00:05:47,980 --> 00:05:56,460
I basically just only replace that one line from the last program that had a scene with the opposite

80
00:05:56,460 --> 00:05:59,850
of this symbol, you know, greater than greater than an input.

81
00:06:01,340 --> 00:06:07,430
That that line has been replaced with this line, Line eight is now get line with the scene and input.

82
00:06:08,390 --> 00:06:16,430
And so when I type blah space, blah, it doesn't stop on the space in between these, it grabs the

83
00:06:16,430 --> 00:06:19,880
first word blah and the space and the second word blah.

84
00:06:20,720 --> 00:06:26,510
And then what happens is it actually stops on in the new line character.

85
00:06:26,510 --> 00:06:29,660
So it reads everything up until the new line character.

86
00:06:29,960 --> 00:06:34,490
The new line character is here because we pressed enter at the end of this.

87
00:06:35,060 --> 00:06:40,160
When I entered the name, I said, Blah space, blah, and I pressed enter.

88
00:06:40,160 --> 00:06:42,170
And that added, when I press enter.

89
00:06:42,170 --> 00:06:47,150
It added the new line on the end of all this stuff on the keyboard buffer.

90
00:06:47,150 --> 00:06:54,680
And so when you get line past all this stuff and it hit the new line, it was like, Oh, I grab everything,

91
00:06:54,680 --> 00:06:56,240
everything, everything hit a new line.

92
00:06:56,750 --> 00:07:03,950
Not going to grab that, not going to save that on to the variable input, but I'm going to stop.

93
00:07:05,090 --> 00:07:12,470
So it reads everything up to the new line and it reads the new line, but it does not put the new line

94
00:07:12,470 --> 00:07:13,820
into your input.

95
00:07:14,270 --> 00:07:22,160
If it did put the new line into the input, it would add like an extra new line on the output PowerShell

96
00:07:22,160 --> 00:07:23,810
kind of automatically to this new line.

97
00:07:23,870 --> 00:07:28,310
But if you were to run this in a different terminal, that's not PowerShell.

98
00:07:29,750 --> 00:07:37,520
You could see that if you were to not add this in line, then it would still just smash up right against

99
00:07:37,520 --> 00:07:39,380
the prompt right here and the prompt.

100
00:07:39,680 --> 00:07:44,450
This whole prompt would not be on a new line because the new line character would not be added on to

101
00:07:44,450 --> 00:07:45,860
the end of the input variable.

102
00:07:47,300 --> 00:07:54,290
It would just simply be blah blah, and it would only have it in line if you added the inline when you

103
00:07:54,890 --> 00:07:55,700
were doing SEO.

104
00:07:58,360 --> 00:08:00,490
So definitely pretty interesting.

105
00:08:01,780 --> 00:08:10,420
So let's go straight into a practice problem now that we have gone over this, so we're going to keep

106
00:08:10,420 --> 00:08:16,750
rolling with the password program idea, but we're going to make another one of those programs where

107
00:08:16,750 --> 00:08:18,640
the user needs to guess a password.

108
00:08:18,760 --> 00:08:22,440
But this time we're going to take the user's input as a string.

109
00:08:23,470 --> 00:08:29,980
We're also going to do the same thing and compare it to a hard coded string, which will be the password,

110
00:08:29,990 --> 00:08:32,050
so you're going to come up with it yourself.

111
00:08:32,500 --> 00:08:40,330
You'll be like string password equals and then some double quotes and whatever you want the password

112
00:08:40,330 --> 00:08:40,900
to be called.

113
00:08:41,980 --> 00:08:47,260
If the user enters something that is not long enough.

114
00:08:47,920 --> 00:08:51,670
So kind of hinting at you needing to use a function, right?

115
00:08:52,240 --> 00:08:57,550
Meaning you use a certain function to know how long the string is that the user enters, says the user

116
00:08:57,550 --> 00:08:59,350
enters something that's not long enough.

117
00:08:59,370 --> 00:09:03,560
He'd print out a message and is too short if they enter something too long.

118
00:09:03,580 --> 00:09:07,450
You need to print out a message as too long if they enter something that's the right length.

119
00:09:08,170 --> 00:09:12,520
But it's not the correct password you need to tell them it's the right length, but it's still wrong.

120
00:09:13,210 --> 00:09:17,100
If the user does enter the right length and if the right password, you let them know.

121
00:09:17,110 --> 00:09:18,850
So here's some example output here.

122
00:09:19,570 --> 00:09:21,130
So says What's the password?

123
00:09:21,610 --> 00:09:23,020
One two three four was entered.

124
00:09:23,020 --> 00:09:25,030
That was too short, so it said too short.

125
00:09:25,960 --> 00:09:27,940
Once again, we put safe password.

126
00:09:27,940 --> 00:09:29,200
Is this this is too long?

127
00:09:30,430 --> 00:09:34,750
Asks again if a password is says correct length, but it's the wrong password.

128
00:09:35,710 --> 00:09:41,110
And then finally do safe pass, and it just says, you guessed it, because that is the correct password.

129
00:09:43,270 --> 00:09:47,470
OK, cool, so this one might be a little bit challenging.

130
00:09:48,990 --> 00:09:55,350
The solution that I'm going to show you after you've tried this yourself will involve.

131
00:09:57,800 --> 00:10:07,280
A new thing or two and might involve something that you haven't necessarily done before, it's not really

132
00:10:07,280 --> 00:10:14,030
a new concept, but it involves using the conditionals in an interesting way.

133
00:10:14,330 --> 00:10:18,890
But I'm trying to challenge you to try and challenge you to figure it out.

134
00:10:19,640 --> 00:10:24,680
I would really recommend that you do your absolute best no matter how long it takes.

135
00:10:24,950 --> 00:10:29,810
You can just stop the video here and keep working on this until you can figure it out.

136
00:10:30,140 --> 00:10:36,380
Do not immediately watch the solution unless you have completely exhausted all of your ideas on how

137
00:10:36,380 --> 00:10:37,250
to solve this.

138
00:10:37,640 --> 00:10:40,160
So with that, go ahead and pause.

139
00:10:40,460 --> 00:10:44,390
Stop the video and try and solve this on your own.

140
00:10:46,710 --> 00:10:54,750
OK, so now I am going to go on to the ED and show you a solution and kind of walk you through it and

141
00:10:54,750 --> 00:10:55,470
explain it.

142
00:10:59,020 --> 00:11:07,000
So I'm going back over here, but I have another file called Get Line, I'm going to clear the console

143
00:11:07,000 --> 00:11:07,300
here.

144
00:11:08,990 --> 00:11:09,500
So.

145
00:11:10,750 --> 00:11:14,950
This is how I would have written this, how I did write it.

146
00:11:15,160 --> 00:11:20,260
So first off, we come up with a password, right?

147
00:11:21,290 --> 00:11:24,350
So here is a strong data type.

148
00:11:24,380 --> 00:11:30,620
Here is our variable name called password, and we immediately initialize it with the assignment operator

149
00:11:31,370 --> 00:11:33,830
to safe pass and double quotes.

150
00:11:35,240 --> 00:11:39,890
Here we create a string that's just declared, but we don't initialize it.

151
00:11:39,890 --> 00:11:45,680
We just declare a string called input, and we're going to read from the user into that with get line.

152
00:11:46,250 --> 00:11:51,740
But before we do that, when you see out, we're going to say, what's the password as just a preliminary

153
00:11:51,740 --> 00:11:52,850
message to the user.

154
00:11:53,770 --> 00:12:00,640
At this point, we can then use the get line function and we can use sea in which his counsel and to

155
00:12:00,640 --> 00:12:03,520
read into our variable or our input variable.

156
00:12:03,530 --> 00:12:04,510
So you see that you.

157
00:12:07,180 --> 00:12:11,140
So the next part is doing all the checks, right?

158
00:12:11,410 --> 00:12:17,440
So remember this dot length function that is something that we have talked about before, and now it

159
00:12:17,440 --> 00:12:18,370
comes in handy.

160
00:12:19,570 --> 00:12:27,250
So I just kind of hardcoded the value here because this is eight, but you could also do something.

161
00:12:27,310 --> 00:12:35,680
It would probably be better is to do password length because then if I wanted to change the password

162
00:12:35,680 --> 00:12:39,280
to something else, I wouldn't have to go change my if stuff.

163
00:12:41,790 --> 00:12:48,180
So we check real quick to see if the input is not equal to the password, but you might notice something

164
00:12:48,180 --> 00:12:49,830
interesting here about this.

165
00:12:50,610 --> 00:12:57,690
There's an if and then open bracket and then there is stuff like another if inside of it.

166
00:12:59,810 --> 00:13:04,080
So this is kind of a new concept, this is something called nesting.

167
00:13:04,730 --> 00:13:11,720
So when you put some type of code thing inside of.

168
00:13:13,420 --> 00:13:18,760
Itself basically not itself, but you have the same type of thing inside.

169
00:13:19,330 --> 00:13:25,290
So here we have an F and inside of the if we have another, if that is called nesting.

170
00:13:25,660 --> 00:13:28,390
So we're nesting conditional statements.

171
00:13:29,800 --> 00:13:35,360
So it's not only an if it's an f and else if and an else all contained inside this.

172
00:13:35,380 --> 00:13:38,680
If so, let me kind of explain the structure here.

173
00:13:39,550 --> 00:13:45,160
What we're trying to do is we first want to look at a specific condition, right?

174
00:13:45,910 --> 00:13:51,070
We want to look at the condition in which the user has not guessed the password.

175
00:13:51,400 --> 00:13:56,740
So that means that the input is not equal to the password.

176
00:13:58,070 --> 00:13:58,610
So.

177
00:13:59,690 --> 00:14:08,240
If this is true, then we want to now consider more conditions, right, because we want to display

178
00:14:08,510 --> 00:14:17,030
specific answers depending on whether they have put too little amount of characters or too much.

179
00:14:18,340 --> 00:14:22,840
So I'm also going to replace this with a password length.

180
00:14:26,220 --> 00:14:33,270
So what we do is if they have not put in the correct password, then we are going to check again with

181
00:14:33,270 --> 00:14:36,750
a different if and in fact, that's going to have some.

182
00:14:36,750 --> 00:14:43,710
And if an infinite asked the first if is going to say it's less check if it's less characters than it's

183
00:14:43,710 --> 00:14:47,640
supposed to be, in which case we will say to short.

184
00:14:49,660 --> 00:14:55,780
Else, if so, only one of these is going to run, there's either a three different options, it's either

185
00:14:55,780 --> 00:15:02,290
they put something that's too small, either they put something that's too big, which where we say

186
00:15:02,290 --> 00:15:02,950
too long.

187
00:15:04,330 --> 00:15:09,970
Else, which is the last condition that means it's not too big or it's not too small or too big, it's

188
00:15:09,970 --> 00:15:11,050
the correct length.

189
00:15:11,290 --> 00:15:20,620
But the fact is is that this LS, in fact, all this is contained in contingent upon this passing.

190
00:15:20,620 --> 00:15:21,850
This if needs to pass.

191
00:15:21,860 --> 00:15:25,930
So this means that it's definitely not the right password.

192
00:15:26,680 --> 00:15:28,210
But when we get down here.

193
00:15:29,230 --> 00:15:32,860
It's not too little or not too big, but it still isn't right.

194
00:15:33,370 --> 00:15:37,330
So in the house, we're going to say correct length, but wrong password.

195
00:15:39,120 --> 00:15:47,940
Then on this outer layer where we had the if you notice we put the closed bracket here for this, if

196
00:15:47,940 --> 00:15:55,800
appear, we're going to have an elf that gets matched with this f, which is the opposite of this condition

197
00:15:55,800 --> 00:15:56,240
right here.

198
00:15:56,250 --> 00:15:56,580
So.

199
00:15:57,550 --> 00:16:02,530
All of this stuff in here was what we wanted to happen.

200
00:16:03,080 --> 00:16:09,340
You know, we would check each one of these only if they did not enter the right password down here,

201
00:16:09,340 --> 00:16:16,180
though, there's an else that's on this same line, this indentation level, which is the opposite.

202
00:16:16,210 --> 00:16:21,670
So if this actually is true, if the input is equal to the password.

203
00:16:22,510 --> 00:16:24,820
So when I say true, I don't actually mean.

204
00:16:26,530 --> 00:16:33,760
When I say true, in this instance, I'm saying if input equals equals password, not not input, not

205
00:16:33,760 --> 00:16:34,600
equal to password.

206
00:16:34,610 --> 00:16:39,100
So if this evaluates to true, all this stuff goes down in here.

207
00:16:39,100 --> 00:16:42,880
But if this evaluates to false, then we jump straight to the else.

208
00:16:44,010 --> 00:16:48,390
In which case it is the correct password input.

209
00:16:48,810 --> 00:16:52,470
Equals equals password is what else represents.

210
00:16:53,130 --> 00:17:00,150
And so we're going to say, you guessed it, so a little bit confusing that we have, you know, and

211
00:17:00,150 --> 00:17:07,230
if and else if it else inside of another if, but really it's like layers of.

212
00:17:08,140 --> 00:17:09,410
Conditions, right?

213
00:17:09,430 --> 00:17:13,900
So it's kind of like you can think of it as a test, right?

214
00:17:15,140 --> 00:17:21,770
OK, so we're going to give someone three tests if they.

215
00:17:22,930 --> 00:17:30,970
If they don't pass the first test or something like that, you know, so let's say we want this condition

216
00:17:30,970 --> 00:17:39,490
like, all right, we're going to give some people a test and if they fail.

217
00:17:40,710 --> 00:17:46,920
The first test, then we're going to give and we're going to test him on three other things.

218
00:17:48,300 --> 00:17:49,890
Three other conditions or something.

219
00:17:50,490 --> 00:17:54,840
But if they do pass, it will immediately just say you passed.

220
00:17:56,250 --> 00:17:59,910
So this is the case in which this test fails.

221
00:18:00,890 --> 00:18:05,520
So if the test fails, then we want to initiate some other tests.

222
00:18:05,540 --> 00:18:09,080
You know, this test right here is like, whom did they get it?

223
00:18:09,500 --> 00:18:11,240
What did they put something to short?

224
00:18:12,750 --> 00:18:13,370
OK.

225
00:18:13,680 --> 00:18:17,190
Separately, maybe they put something that was too big.

226
00:18:18,650 --> 00:18:23,840
OK, if it's neither of those, that means it's the same length, so we only went through all of this

227
00:18:23,840 --> 00:18:26,450
logic if they failed.

228
00:18:27,850 --> 00:18:32,380
Right off the bat, you know, they failed to enter the password, then we're going to do all this other

229
00:18:32,380 --> 00:18:33,160
stuff in here.

230
00:18:33,730 --> 00:18:37,460
If they got it correct, there's no need to ask these questions, right?

231
00:18:37,480 --> 00:18:39,340
There's no need to do these checks.

232
00:18:39,580 --> 00:18:42,370
We don't need to do these if else checks.

233
00:18:43,310 --> 00:18:46,530
Because they got it right, we can immediately just be like, you guessed it.

234
00:18:46,550 --> 00:18:50,780
That's why if this evaluates to false.

235
00:18:52,450 --> 00:18:55,210
Then we're going to jump straight to the else and do this.

236
00:18:56,470 --> 00:19:02,440
So this is kind of more an exercise almost unconditional than it was on the get line, but we still

237
00:19:02,440 --> 00:19:03,910
incorporated the get line.

238
00:19:04,720 --> 00:19:10,930
You notice the get line is a new and completely needed because we don't have any spaces in here.

239
00:19:10,930 --> 00:19:15,190
But if we wanted, we could have something with spaces, right?

240
00:19:16,030 --> 00:19:22,450
So what it could do is put a space in here and call it Safe Space Pass.

241
00:19:24,880 --> 00:19:27,490
And then I do get like a copy.

242
00:19:33,230 --> 00:19:38,390
And then I'm going to run, actually, I did not save this, so I have to re compile this.

243
00:19:43,790 --> 00:19:44,990
What's the password?

244
00:19:45,350 --> 00:19:51,710
And I say Safe Passage says it's too short because it's counting this space in between here.

245
00:19:52,340 --> 00:19:53,780
It's not a anymore.

246
00:19:53,900 --> 00:19:58,100
It's a nine one two three four five six seven eight nine.

247
00:19:59,380 --> 00:20:00,970
So, you know, an inch of that.

248
00:20:01,300 --> 00:20:04,840
And if I do safe path, then it says, you guessed it.

249
00:20:06,330 --> 00:20:13,800
So pretty cool, that's probably, you know, this will this will make it so if there was a if a space,

250
00:20:13,800 --> 00:20:14,990
it would be totally fine.

251
00:20:15,000 --> 00:20:21,170
And of course, if it was, you know, it would accept it on the user input, it really is.

252
00:20:21,180 --> 00:20:27,180
What the important part is is that when we're using seeing as the input, if we put a space, it's totally

253
00:20:27,180 --> 00:20:28,620
fine and it's going to read that space.

254
00:20:31,470 --> 00:20:38,490
OK, so if you were able to figure this out, definitely perhaps to you as always, but if not, you

255
00:20:38,490 --> 00:20:44,340
know, don't worry, this is kind of a hard one, this nested conditional thing, but I'm kind of sprinkling

256
00:20:44,340 --> 00:20:45,540
these into the problem.

257
00:20:45,540 --> 00:20:52,740
So even if I have a figure now, it gives me an opportunity to mix some other concepts that we don't

258
00:20:52,740 --> 00:20:58,140
necessarily need to have a whole video about, don't need to have a whole video about nesting conditions.

259
00:20:58,920 --> 00:21:04,350
The fact is is you can just keep nesting conditions like, you know, over and over and over again.

260
00:21:04,350 --> 00:21:13,380
Like you can just say, if you know, if a equals equals a, you know, some ridiculous thing like this,

261
00:21:13,380 --> 00:21:15,150
then you know, if

262
00:21:18,570 --> 00:21:20,730
false, you know, which wouldn't work.

263
00:21:20,730 --> 00:21:22,860
But it's true.

264
00:21:22,860 --> 00:21:29,400
And then like if you know, you could just put a ton of stuff like if, if, if, if, if, like so

265
00:21:29,400 --> 00:21:31,590
deep into here, like you can just keep going.

266
00:21:32,340 --> 00:21:33,690
We don't necessarily need that.

267
00:21:33,690 --> 00:21:39,560
But the fact of the matter is you can do as much nesting of these as if you want in the LCF.

268
00:21:39,560 --> 00:21:48,690
If you can also put in another, if in the else, you can put another if and you know, of course,

269
00:21:48,690 --> 00:21:55,030
wherever you're putting these, if you can do more if and also so it can be just going forever.

270
00:21:55,050 --> 00:22:07,140
You know, if something if you know something else and then else if and then and else here, you know,

271
00:22:07,230 --> 00:22:09,330
you can keep structuring things like this.

272
00:22:11,360 --> 00:22:13,940
So pretty cool, pretty interesting.

273
00:22:15,170 --> 00:22:19,400
And go ahead and just delete this, because that's not necessary.

274
00:22:23,910 --> 00:22:28,290
OK, so let's go ahead and head back to the lecture.

275
00:22:29,130 --> 00:22:35,550
So congrats if you were able to figure this out, if not, don't worry, just go ahead and practice

276
00:22:35,550 --> 00:22:41,160
that nesting of the F and LCF and stuff like that so you can get comfortable with it.

277
00:22:43,320 --> 00:22:47,340
One last thing we're going to talk about is a cool little function called get.

278
00:22:47,730 --> 00:22:54,690
So it basically is kind of like get line, except it just reads a single character.

279
00:22:56,160 --> 00:23:01,410
So but like it line, it doesn't refuse the way it's fake whitespace characters.

280
00:23:01,620 --> 00:23:04,170
This is kind of not completely true, right?

281
00:23:04,200 --> 00:23:07,110
Because, uh, get line.

282
00:23:07,260 --> 00:23:09,870
Does it stop on the new line?

283
00:23:10,840 --> 00:23:13,330
And the new line is a slash in.

284
00:23:15,140 --> 00:23:16,490
So you saw that up here, right?

285
00:23:17,420 --> 00:23:23,480
New line character, I didn't explain this much, but when you press enter, it is kind of seen as this

286
00:23:23,570 --> 00:23:27,560
slash and that's a new line, right?

287
00:23:28,490 --> 00:23:37,760
So get line, it will not refuse like space presses, you know, when we see a space between something

288
00:23:38,180 --> 00:23:40,160
kind of like, you know, this space like this.

289
00:23:41,670 --> 00:23:47,340
But it will stop on the new line, the thing about ghetto, though, is get will actually grab that

290
00:23:47,340 --> 00:23:48,270
new line character.

291
00:23:48,270 --> 00:23:54,360
Unlike Get Line Get is going to actually take this and store it into a variable if you want.

292
00:23:55,530 --> 00:23:58,950
It does not like stop on the new line.

293
00:23:58,980 --> 00:24:04,530
It totally just like, you know, absorbs it and we'll read it into an input.

294
00:24:04,530 --> 00:24:07,260
If you want a cool thing you can use.

295
00:24:07,260 --> 00:24:10,020
Get for, though, is pausing your program.

296
00:24:10,380 --> 00:24:16,020
We're not really going to be using a whole lot until we deal with reading the input from files that

297
00:24:16,020 --> 00:24:18,570
will be separately using something called a file stream.

298
00:24:19,200 --> 00:24:26,730
And we can use get for that read character by character and that get will not ignore any character.

299
00:24:26,760 --> 00:24:33,180
Get is going to get any single character that can be pressed on your keyboard, basically, so it does

300
00:24:33,180 --> 00:24:35,370
not exclude anything.

301
00:24:35,670 --> 00:24:37,020
That's a cool thing about it.

302
00:24:37,680 --> 00:24:42,990
So because of that is pretty handy to just start the program because and if you wanted to, you could

303
00:24:42,990 --> 00:24:51,210
save the new line here and you could do that by putting a variable equals C and get so like using the

304
00:24:51,210 --> 00:24:54,300
assignment operator, you could say like char.

305
00:24:55,560 --> 00:25:02,030
GRC and then you can say C equals C and get something like that, you can also put the character in

306
00:25:02,030 --> 00:25:03,800
the parentheses and pass to it.

307
00:25:05,410 --> 00:25:08,950
But that's how you can call it, you can do a C and get.

308
00:25:09,550 --> 00:25:10,810
That's the syntax.

309
00:25:11,140 --> 00:25:12,880
It is one of the dot ones.

310
00:25:15,340 --> 00:25:22,060
So you notice here in this little example, what it does is it basically pauses and waits for the entire

311
00:25:22,060 --> 00:25:25,000
key to be pressed for it to continue.

312
00:25:26,140 --> 00:25:31,570
So something we're not going to focus on a lot right now because we don't really need it, but we will

313
00:25:31,570 --> 00:25:38,260
be looking at it later when we're reading input from files because it is useful for looking at character

314
00:25:38,260 --> 00:25:40,570
by character, everything that's in a file.

315
00:25:41,020 --> 00:25:48,070
So if the one way you can be, like, very, very meticulous in the way that you are checking all of

316
00:25:48,070 --> 00:25:51,580
the contents of the file, something cool will get into later.

317
00:25:52,130 --> 00:25:59,410
Right now, focus on using get line and see in and understanding the differences between those and when

318
00:25:59,410 --> 00:26:00,280
you can use them.
