Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d791ed3
Added Name To FIle
medioloquito Sep 5, 2018
49de7e6
Updated README.md file content
medioloquito Sep 5, 2018
ac9d628
Adding HelloWorld Python File
medioloquito Sep 5, 2018
57e8aa8
Added Original MadLibs.py code
medioloquito Sep 9, 2018
cd0a027
Initial upload of MadLibs.py app code.
medioloquito Sep 9, 2018
411cca5
General code refinements
medioloquito Sep 10, 2018
180c385
Update MadLibs.py
medioloquito Sep 10, 2018
aa9249c
Ensuring version matching. No expexted changes.
medioloquito Sep 12, 2018
c735e2f
Commit message
medioloquito Sep 13, 2018
a58b1f6
Merge branch 'Travis' of https://github.com/medioloquito/Programming-…
medioloquito Sep 13, 2018
5eb716b
VimCrypt~01!±¾?ä'ΜaôE¡=-{֜ÁšÛÃý oV!¨ÜésˆÄ ó]bšÒðµàóæäzíû Jõ\$…
medioloquito Sep 26, 2018
964002d
Added code deficiency comment at top of code to discuss with Nick
medioloquito Sep 26, 2018
3739557
Initial App Upload
medioloquito Sep 26, 2018
2f34d21
Simple output format update
medioloquito Sep 26, 2018
9a19002
Updated to include logic for range and number of attempts
medioloquito Sep 26, 2018
ed4f135
Updated to correct loop list creation error
medioloquito Oct 11, 2018
309d5d1
Updated to reveal number if not guessed in alloted attempts.
medioloquito Oct 11, 2018
88d4ce5
Added comment at the top.
medioloquito Oct 11, 2018
053bd17
Initial upload of application.
medioloquito Oct 12, 2018
9074069
Code refinements made
medioloquito Oct 12, 2018
60c862c
Added additional logic for multiple phone entries
medioloquito Oct 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions AddressBook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
##Address Book Program

import sys

filename = 'AddressBook.txt'

sWelcomePrompt = ('Welcome to Little Black Book! This program will allow you to add'
'\nan unlimited number contacts and the associated information for each.'
'\nIf you do not want to enter anything for a given field, just press ENTER'
'\nor follow field-specific prompts.'
'\n\n**Press ENTER to begin entering your contact information!**\n')

lb = '\n'
sName = 'Name: '
sPhone = 'Phone Number'
sPhoneType = 'Enter "H" if this is a HOME number or W if this is a WORK number: '
sEmail = 'Email Address'
sEmailType = 'Enter "H" if this is a HOME email or W if this is a WORK email: '
sAddress = 'Physicial Address: '
sBirthday = 'Birthday: '
sNickname = 'Nickname(s): '
sOccupation = 'Occupation: '
sCompany = 'Company: '
sSectionBreak = '-----------------------------------------------------------'
sAddMore = ('Your file has been updated.'
'\nIf you wish to add more contacts, type "Y" and press ENTER.'
'\nType "N" and press ENTER to stop and view your contact list.'
'\nOr, simply press ENTER to exit the program.' + lb)
lstTypes = ['H','h','W','w']

def homeVSwork(x,sInputVerbiage,sPrompt):
while x not in lstTypes:
x = input('Please enter a valid response.\n' + sPrompt)
if x == 'H' or x == 'h':
y = sInputVerbiage + ' (Home)'
elif x == 'W' or x == 'w':
y = sInputVerbiage + ' (Work)'
return(y)

def storeInput(filename,enteredValues,cntNumEntries):
if cntNumEntries == 1:
f = open(filename,'w+')
else:
f = open(filename,'a')
for i in enteredValues:
f.write(i)
f.close

def getInput(filename,read):
fileOutput = open(filename,read)
print(fileOutput.read())
fileOutput.close()

def reqFld(x,sPrompt):
while x == '':
print('You must enter a value for this field.')
x = input(sPrompt)
return x

def Main():
input(sWelcomePrompt)
#Throw this all into a While loop for as long as the user wants to add more entries
input_sAddMore = 'Y'
cntAddition = 0
while input_sAddMore == 'Y' or input_sAddMore == 'y':
lb
lb
input_sName = reqFld(input(sName),sName)
input_sPhone = reqFld(input(sPhone + ': '),sPhone)
phoneNumLoopVar = 'x'
lstPhoneNumbers = list()
while phoneNumLoopVar != '':
if input_sPhone == '':
input_sPhone = input('Additional ' + sPhone + ' or press ENTER: ')
if input_sPhone != '':
input_sPhoneType = input(sPhoneType)
input_sPhone = homeVSwork(input_sPhoneType,input_sPhone,sPhoneType)
lstPhoneNumbers.append(input_sPhone)
phoneNumLoopVar = input_sPhone
input_sPhone = ''
sTmp = ''
length_lstPhoneNumbers = int(len(lstPhoneNumbers))
cntPhone = 1
for i in lstPhoneNumbers:
if cntPhone != length_lstPhoneNumbers:
sTmp = sTmp + sPhone + i + '\n'
else:
sTmp = sTmp + sPhone + i
cntPhone = cntPhone + 1
input_sPhone = sTmp
cntEmail = 1
canEnterAdditionalEmail = True
input_2nd_email = ''
exists2ndEmail = False
while cntEmail <= 2:
if canEnterAdditionalEmail is True:
input_sEmail = input(sEmail + ' #{}: '.format(cntEmail))
input_1st_email = ''
if cntEmail == 1 and input_sEmail != '':
input_1st_email = input_sEmail
exists1stEmail = True
elif cntEmail == 1 and input_sEmail == '':
exists1stEmail = False
canEnterAdditionalEmail = False
if exists1stEmail is True and cntEmail == 2:
if input_sEmail != '':
input_sEmailType = input(sEmailType)
input_2nd_email = homeVSwork(input_sEmailType,input_sEmail,sEmailType)
if input_2nd_email != '':
input_sEmail = (' #1: ' + input_1st_email + lb + sEmail + ' #2: ' + input_2nd_email)
exists2ndEmail = True
if exists1stEmail is True and (exists2ndEmail is False or input_2nd_email == ''):
input_sEmail = input_1st_email + ':'
cntEmail = cntEmail + 1
input_sAddress = input(sAddress)
input_sBirthday = input(sBirthday)
input_sNickname = input(sNickname)
input_sOccupation = input(sOccupation)
input_sCompany = input(sCompany)
fileInput = (sName + input_sName + lb + sPhone + input_sPhone + lb +
sEmail + input_sEmail + lb + sAddress + input_sAddress + lb +
sBirthday + input_sBirthday + lb + sNickname + input_sNickname + lb +
sOccupation + input_sOccupation + lb + sCompany + input_sCompany + lb +
sSectionBreak + lb)
if fileInput != '':
cntAddition = cntAddition + 1
storeInput(filename,fileInput,cntAddition)
input_sAddMore = input(sAddMore)
if input_sAddMore == 'N' or input_sAddMore == 'n':
lb
getInput(filename,'r')
Main()
Loading