Skip to content

Latest commit

 

History

History
87 lines (61 loc) · 1.13 KB

007_Print_Function.md

File metadata and controls

87 lines (61 loc) · 1.13 KB

007 - Print Function

Task

Read an integer N .

Without using any string methods, try to print the following: 123...N

Note that "..." represents the values in between.

Input Format

The first line contains an integer N.

Output Format

Output the answer as explained in the task.

Sample Input :
3
Sample Output :
123

Given Code

if __name__ == '__main__':
    n = int(input())

Solution 1

if __name__ == '__main__':
    n = int(input())
    print(*range(1, n + 1), sep="")

Solution 2

if __name__ == '__main__':
    n = int(input())
    print("".join([str(x) for x in range(1,n+1)]))

Solution 3

if __name__ == '__main__':
    n = int(input())
    lst = [x for x in range(1,n+1)]
    print(*lst, sep="")

Solution 4

if __name__ == '__main__':
    n = int(input())
    lst = ""
    for num in range(1, n+1):
      lst += str(num)
    print(lst)

Solution 5

if __name__ == '__main__':
    n = int(input())
    lst = []
    for num in range(1, n+1):
      lst.append(str(num))
    print("".join(lst))