Click here to Skip to main content
15,896,526 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I started solving challenges on Hackerrank using python. There is a problem I encountered. I am a beginner in coding and it would be great if someone could help me out with the code.

Problem statement:-Read an integer N and the output should be '1,2,3....N'

e.g:- If '5' is the input then output should be '1,2,3,4,5'

What I have tried:

Tried to put it into an array but the output is like [1,2,3,4,5] which isnt the desired one.
Posted
Updated 19-Mar-18 22:18pm
Comments
Patrice T 20-Mar-18 4:10am    
and you have some code ?
Sushmit Chakraborty 20-Mar-18 4:24am    
Yes my code is using a simple for loop-

n = int(raw_input())
values=[]
for i in range(1,n+1):
values.append(i)
print (values)

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900