Added code for lecture 2026-11-10
This commit is contained in:
parent
5b630435ae
commit
07b9e54bf0
52 changed files with 1248 additions and 1 deletions
24
lecture20261110/listmethods/list10MethodReverse.py
Normal file
24
lecture20261110/listmethods/list10MethodReverse.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/python3
|
||||
# Program: list09MethodReverse.py
|
||||
|
||||
programMessage = '''
|
||||
This program reverses a list.
|
||||
'''
|
||||
print(programMessage)
|
||||
|
||||
|
||||
# Lists of text values
|
||||
dogNames = [ "Harry", "Shenanigans","Katrina","Tanner","Yukon Jack", "Colorado","Mandy"]
|
||||
|
||||
|
||||
# Print the list and the length
|
||||
print("Print the length and type of the list.")
|
||||
print (dogNames," length = ",len(dogNames),"Type =",type(dogNames))
|
||||
|
||||
print("\nReverse the list")
|
||||
|
||||
dogNames.reverse()
|
||||
print("Print the length of the reversed list.")
|
||||
print (dogNames)
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue