0

Plz Explain the output of this code

for n in range(1,7) print(7//n, end="")

22nd Dec 2020, 9:22 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
2 Answers
+ 2
range(1, 7) starts with 1 and ends with 6 7 // 1 => 7 7 // 2 => 3 7 // 3 => 2 7 // 4 => 1 7 // 5 => 1 7 // 6 => 1
22nd Dec 2020, 9:43 AM
Ipang
+ 7
The output of that code would be an error because you need a colon at the end of the first line and need to indent the second line. Then following up on what Ipang said, the output would be 732111 because the end character has been changed from the default "\n" to "".
22nd Dec 2020, 9:50 AM
David Ashton
David Ashton - avatar