#!/usr/bin/python3
def main():
check = input('\nDo you want to store usernames? (y/n)')
if check != "n" and check != "y":
print ('\nInvalid Input')
return main()
elif check != 'n' or 'N':
output = input('\nWhat should the name of the file be, containing the username(s) be? ')
out = open(output)
if output == ' ' or '':
main()
else:
while check != 'N' or 'n':
uName = []
number = int(input('How many usernames do you have?'))
for x in range(number):
first = input('\n First Name: ')
last = input('\n Last Name: ')
try:
uName.append((first[0] + last[:(len(last)/2)]))
output.write(uName[x] + '\n')
except ValueError:
print ('Something went wrong')
finally:
out.close()
again = input('\nDo you want to add more? (y,n) ')
if again == 'n' or 'N':
print ('\nStored. Exiting program')
out.close()
return
elif again == 'n' or 'N':
print('Nothing Stored.')
main()
Thanks to sepp2k and Dogstopper, I have surpassed the previous error however I am greeted with a new one.
Traceback (most recent call last):
File "/home/k3y/Python/Look2.py", line 37, in <module>
main()
File "/home/k3y/Python/Look2.py", line 22, in main
uName.append((first[0] + last[:(len(last)/2)]))
TypeError: slice indices must be integers or None or have an __index__ method

New Topic/Question
Reply





MultiQuote




|