I was watching this complete Python Tutorial by Mosh Hamadani on youtube.
I saw a small piece of code that he wrote and I wrote it in pycharm.
I got an output that was different from what he got.
This is a program to find the largest number.
This is the piece of code.
Where did I go wrong?
I saw a small piece of code that he wrote and I wrote it in pycharm.
I got an output that was different from what he got.
This is a program to find the largest number.
This is the piece of code.
numbers = [11, 2, 23, 45, 67, 99, 101]
largest_num = numbers[0]
for number in numbers:
if number > largest_num:
largest_num = number
print(largest_num)The result was Output:23
45
67
99
101But, The intended result was 101, the largest number.Where did I go wrong?
