Hackerrank | Python | Print Function

Опубликовано: 21 Сентябрь 2023
на канале: Programming with Sikander
167
1

This video is a part of Hackerrank Python problem solving Series.
In this question we are supposed to print the numbers from 1 to n in a single line and there should not be any space between the numbers.
The object of this question is to understand two important parameters of print function, end and sep.
I have demonstrated using two methods, first using a for loop to print numbers from 1 to n and using end parameter.
Second method I have used sep parameter.

n = int(input())

for i in range(1 , n + 1):
print(i , end = '')
#----------------------------------------------------------------
n = int(input())
print( *range(1 , n + 1) , sep = '')

Link to Code: https://godbolt.org/z/rqxrs59fW

For more videos of Hackerrank, refer below playlist.
   • Hackerrank Solutions in Python  

#hackerranksolutions #hackerrank #python
#hackerrankpython


На этой странице сайта вы можете посмотреть видео онлайн Hackerrank | Python | Print Function длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Programming with Sikander 21 Сентябрь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 167 раз и оно понравилось 1 зрителям. Приятного просмотра!