repl.it
@JosephLooney/

Lists/Dictionaries

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
aList = [4,1,3,5,6,7,8]
print (aList[:4])# < 4th index
print (aList[4:])# >= 4

bList = [4,4,2,5,6,7,3] 
print(bList[::-1])

#Ask the user for the number of items the user wants to enter.  Add those elements to a list.  Using list methods, find the highest value and print for the user. Sinjin might be copying my code.

items=int(input("How many items do you want in your list?"))
ctr=0
meList=[]
for i in range(1,items+1):
	add=input("Type an item to add to the list.")
	meList.append(add) #if Sinjin submits this, i wrote it first.
print(meList) #prints it sinjindontcopythis
print(meList[::-1]) #prints it backwards

hollidays={"October 31":"Halloween","December 25":"Christmas","January 1":"New Years","Febuary 14":"Valentines day","April 1":"April fools day","November 18":"The day the most Holy game ever was released","December 21":"Jack's Birthday","October 1":"Dad's birthday","Febuary 17":"Mom's Birthday","August 25":"My Birthday"}
date=input("Type a month and date of a holliday (i.e. January 1)")
if date in hollidays:
	print(hollidays[date])
else:
	print("Sorry, I dont have that hollidat in the dictionary.")

num=int(input("Pick a number(if its more than 30 your pc may crash)"))
nums={}
for i in range(1,num+1):
	nums[i]=i**2
print(nums)

d={"Mark":"Hamill","Mary":"Hill","Darth":"Vader","Mary":"Poppins"}

for i in d:
	print(i+" "+d[i])

num2=int(input("enter a number."))
if num2 == num2[::-1]:
	print("Your number is a palendrome")
else:
	print("Your number is not a palendrome")
Fetching token
?