Share your repls and programming experiences

← Back to all posts
AllLists
DrillingSphere

#this program should have all lists 1-5
names = ["Peter", "Bruce", "Steve", "Tony", "Natasha","Clint", "Wanda", "Hope", "Danny", "Carol"]
numbers = [1, 2, 7, 11, 17, 53, -8, -4, -9, -72, -64, -80, -100, 50, 10]
#am doing the second option.This program should only show the positive numbers

Python program to print positive Numbers in a List

list of numbers

numbers = [1, 2, 7, 11, 17, 53, -8, -4, -9, -72, -64, -80, -100, 50, 10]
num = 0

print("List 1")

for i in range(0, len(names), 2):
print(names[1::2])
#it skips the first name but it works starting from second name to 4th and so on

print("List 2")

using while loop

while(num < len(numbers)):

was able to complete this with the help of https://www.geeksforgeeks.org/python-program-to-print-positive-numbers-in-a-list/

#for some reason list 3 is appearing at the end of 2
print("List 3")

Sum = sum (numbers)
print (Sum)

print("List 4")

Python program to print odd Numbers in a List

list of numbers

iterating each number in list

for nums in numbers:

#list 5 is now also doing the list 3 thing of not going to the next line. Alos 5 has taken sooo long to figure out a code that works.
print("List 5")

initializing check letter

check = 'A'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'B'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'C'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'D'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'E'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'F'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'G'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'H'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'I'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'J'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'K'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'L'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'M'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'N'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'O'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'P'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'Q'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'R'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
check = 'S'

printing original list

using list comprehension + lower()

Words starting with specific letter

res = [idx for idx in names if idx[0].lower() == check.lower()]

print result

print("The list of matching first letter : " + str(res))
#I know this wasn't a loop but its the best I could find online. Sorry that it took me so long to get back to completing this. It's sort of been a hectic and odd week all things considered for me. I should hopefully catch back up in class soon though.

Voters
DrillingSphere