Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How do you sum consecutive numbers in Python?

N = int(input("Please input an integer: "))
i = 1
x = range(1, N + 1)
for i in x:
    nums = range(1, i + 1)
print(int(sum(nums)))


Comment

PREVIOUS NEXT
Code Example
Python :: how to multiply inputs in python 
Python :: plt plot circle 
Python :: python sort list of strings numerically 
Python :: python number to array of digits 
Python :: business logic in django 
Python :: series has no attirubte reshape python 
Python :: counter in sort python 
Python :: xgboost feature importance 
Python :: Python tkinter window fullscreen with title bar 
Python :: como eliminar palabras repetidos de una lista python 
Python :: install python 3.6 mac brew 
Python :: dataframe to txt 
Python :: get distance between 2 multidimentional point in python 
Python :: how to read excel file in jupyter notebook 
Python :: kivymd simple button 
Python :: python nltk tokenize 
Python :: django proper capitalization case jinja 
Python :: E: Unable to locate package python3-pip docker file 
Python :: string array to float array python 
Python :: cv2 load image 
Python :: check package version python 
Python :: iterate over rows dataframe 
Python :: python pygame key input 
Python :: how to play a mp3 file in python 
Python :: number of times a value occurs in dataframne 
Python :: how to add numbers in python using for loop 
Python :: how to change opencv capture resolution 
Python :: python save figure as pdf 
Python :: how to add an active class to current element in navbar in django 
Python :: jupyter no output cell 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =