def ran_keys(issue1,issue2=None):
ran_number = random.sample(data.keys(), 1)
for i in ran_number:
val1 = data.get(i)
n3, s3, t3, r3 = val1
if issue1 == r3:
return val1
else:
if Counter == 1:
ran_keys(first_issue,second_issue)
elif Counter == 2:
ran_keys(first_issue)
def random_mode():
if Counter == 1:
vall = ran_keys(first_issue,second_issue)
name3, s3, t3, r3 = vall
if r3 == first_issue or second_issue:
print('Random selected agent available for your issue = \n')
print('{:<15} {:<15} {:<15} {:<15}'.format('Name', 'Availability', 'Available Since', 'Role'))
print('{:<15} {:<15} {:<15} {:<15}'.format(name3, s3, t3, r3))
else:
print('No agent found for your issue..........\nTry Again..................')
main1()
elif Counter == 2:
vall = ran_keys(first_issue)
name3, s3, t3, r3 = vall
if r3 == first_issue:
print('Random selected agent available for your issue = \n')
print('{:<15} {:<15} {:<15} {:<15}'.format('Name', 'Availability', 'Available Since', 'Role'))
print('{:<15} {:<15} {:<15} {:<15}'.format(name3, s3, t3, r3))
else:
print('No agent found for your issue..........\nTry Again..................')
main1()
This code gives me an error when I run it on terminal. The error is :
File "C:/Users/Acer/Desktop/python_class/project/addCopy.py", line 295, in modes
random_mode()
File "C:/Users/Acer/Desktop/python_class/project/addCopy.py", line 264, in random_mode
name3, s3, t3, r3 = vall
TypeError: cannot unpack non-iterable NoneType object
but when I run it on Python console, it works perfectly fine
Note: The code given above is a part of code so some variables wouldn't be present here.
function ran_keys
returns val1 if issue1 == r3
, but there is no return statement in your else
condition, try:
def ran_keys(issue1,issue2=None):
ran_number = random.sample(data.keys(), 1)
for i in ran_number:
val1 = data.get(i)
n3, s3, t3, r3 = val1
if issue1 == r3:
return val1
else:
if Counter == 1:
return ran_keys(first_issue,second_issue)
elif Counter == 2:
return ran_keys(first_issue)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments