Monday, March 20, 2017

More on loops


# emptyList = []
while (True):
     inputString = input("Add something to the list \nType Q to quit\n")
     if inputString == 'Q':
         print(inputString+ ": is inside of Q")
         break
     print(inputString + ": is outside of Q")
     print ("We ended the loop!W")

 #var are looping from 0 to 4

 for items in range (0,5)
     print(i)
     print ("this is also part of the loop")
     print ("something else")
     print("out of the loop")




numbers =[]
while (True):

        inputString = input("Add something to the list \nType Q to quit\n")
        if inputString == 'Q':
            break
        # print (emptyList)
        print ("\t )
        convertedInput =int(inputString)
        numbers.append(convertedInput)
        # print (emptyList)
    # emptyList = [ne]
#this code runs after the loop
sum =0

for sum in numbers:
    sum =sum + sum
    print ("The current sum is "+ str(sum))

print ("total sum " + str(sum))

No comments:

Post a Comment