Whats up guys! To start off I am really new to python. I got this program that keeps giving me this error message. I was wondering if anyone could help me. Heres the code:
from math import *
from numberTest import *
Lname=['Zdofalos','Johnson','Terrell','Wilson','Key','Smith','Alfonso']
Fname=['Fred','Malcom','Monkey','Wilson', 'LeDoor','Jim Bob','Ralph']
City=['Charlotte','Monroe','Broken Pine','Hogwart','Spot In Road','Denver','Gastonia']
State=['NC','NC','SC','VA','AL','NC','NC']
Zip=['28210','28337','28974','27457','36827','28037','28559']
# =============================================== Menu Items
def main():
sort01 = sort01()
sort02 = sort02()
print 'Which way do you want your list?';print
item1='1 - Enter one for Ascending.'
item2='2 - Enter two for Descending.'
item4='3 - Enter three to exit the program.'
item5='Enter your selection and Press Enter: '
sp=0
# ============================================== Ascending Order
def sort01(sort01):
sort01=len(Zip)
for i in range(sort01-1,0,-1):
for j in range(0,i,1):
if Zip[j] > Zip[j + 1]:
Zip[j],Zip[j + 1] = Zip[j + 1],Zip[j]
State[j],State[j + 1] = State[j + 1],State[j]
City[j],City[j + 1] = City[j + 1],City[j]
Fname[j],Fname[j + 1] = Fname[j + 1],Fname[j]
Lname[j],Lname[j + 1] = Lname[j + 1],Lname[j]
print
print 'The list in ascending order.'
print
print ' Zip State City First Name Last Name'
print '--------------------------------------------------------------'
for i in range(sort01):
print Zip[i],State[i],City[i],Fname[i],Lname[i]
print
print
# =========================================== Descending Order
def sort02(sort02):
sort02=len(Lname)
for i in range(sort02-1,0,-1):
for j in range(0,i,1):
if Lname[j] < Lname[j + 1]:
Lname[j],Lname[j + 1] = Lname[j + 1],Lname[j]
Fname[j],Fname[j + 1] = Fname[j + 1],Fname[j]
City[j],City[j + 1] = City[j + 1],City[j]
State[j],State[j + 1] = State[j + 1],State[j]
Zip[j],Zip[j + 1] = Zip[j + 1],Zip[j]
print
print 'The list in descending order.'
print
print ' Last Name First Name City State Zip'
print '--------------------------------------------------------------'
for i in range(sort02):
print Lname[i],Fname[i],City[i],State[i],Zip[i]
# =============================================== Menu Prompt
def menu():
john=0
while john==0:
print sp*'n'
print sp*' ',item1
print sp*' ',item2
print sp*' ',item3
print
selection=raw_input()
john,selection=testinteger(selection)
if john==1:
if selection<1 or selection>4:
john=0
print 'Your selection is out-of-range!'
raw_input('Press Enter to retry!')
elif selection==1:
sort01()
john=0
elif selection==2:
sort02()
john=0
elif selection==3:
print 'Thanks You for using this program!'
raw_input('Press Enter to exit.')
john=1
else:
print 'There might be a problem with the program!'
return
menu()
I can't seem to figure out how to display the items directly in the colums listed. And heres the error message:
TypeError: range() integer end argument expected, got function.
Thanks for any help.
ADMIN EDIT
Highlight your code next time (shift-up after posting) and push TAB to do easy code formatting.