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):
print(int("1" * i) ** 2)
why is this showing an error as invalid string literal.
My thought is simple as increasing the number of 1 each time loop increases and then printing the square as this series repeats as a square of increasing 1,11,111,1111
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Triangle Quest 2
You are viewing a single comment's thread. Return to all comments →
for i in range(1, n + 1): print(int("1" * i) ** 2)
why is this showing an error as invalid string literal.
My thought is simple as increasing the number of 1 each time loop increases and then printing the square as this series repeats as a square of increasing 1,11,111,1111