how to add numbers in python using for loop
n = input("Enter Number to calculate sum")
n = int (n)
sum = 0
for num in range(0, n+1, 1):
sum = sum+num
print("SUM of first ", n, "numbers is: ", sum )
how to add numbers in python using for loop
n = input("Enter Number to calculate sum")
n = int (n)
sum = 0
for num in range(0, n+1, 1):
sum = sum+num
print("SUM of first ", n, "numbers is: ", sum )
python for loop
#to print number from 1 to 10
for i in range(1,11):
print(i)
#to print a list
l = [1,2,3,4]
for i in l:
print(i)
r = ["a","b","c","d","e"]
s = [1,2,3,4,5]
#print two list with the help of zip function
for p,q in zip(r,s):
print(p,q)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us