We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
for i in range(1, n+1):: This is a for loop that iterates over the range of integers from 1 to n (inclusive). The loop variable i takes on each value in this range during each iteration.
print(i, sep='', end=''): Inside the loop, this line prints the value of i without any separation (sep='') and without adding a newline character at the end (end='').
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Print Function
You are viewing a single comment's thread. Return to all comments →
Explaination:
for i in range(1, n+1):: This is a for loop that iterates over the range of integers from 1 to n (inclusive). The loop variable i takes on each value in this range during each iteration.
print(i, sep='', end=''): Inside the loop, this line prints the value of i without any separation (sep='') and without adding a newline character at the end (end='').