0

Challenge question

x = 5 for x in range (10): x+=1 print(x) print (x+1) why is the answer 11 and not 16

13th Mar 2022, 10:40 AM
PythÞñ CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź
PythÞñ  CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź - avatar
4 Answers
+ 4
But, you reassigned x as iteration variable in for loop. It means x takes the second value as its new value. For example, x = 5 x = 2 print(x) Output: 2 It works like that
13th Mar 2022, 10:57 AM
Simba
Simba - avatar
+ 3
And why did you decide that 16? â˜ș
13th Mar 2022, 10:54 AM
Solo
Solo - avatar
+ 1
Solo in line 1, x was declared as 5
13th Mar 2022, 10:54 AM
PythÞñ CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź
PythÞñ  CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź - avatar
- 1
Simba edited the question sorry
13th Mar 2022, 10:51 AM
PythÞñ CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź
PythÞñ  CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź - avatar