Message342049
program_data.py file contains a list
import list_function
str_list4 = ['i', 't']
str_list4 = list_function.insert_value(str_list4, 's', -1)
print(str_list4)
list_function.py file
def insert_value(my_list, value, insert_position):
counter = 0
print('Question 5')
print(my_list, value, insert_position)
for index in my_list:
counter += 1
when passing the negative number in insert_position between the two modules this causes
str_list4 = list_function.insert_value(str_list4, 's', -1)
File "D:\part A\list_function.py", line 85, in insert_value
for index in my_list:
TypeError: 'NoneType' object is not iterable
my_list now becomes lost, if the negative value is changed to positive this clears up .
if you assign the -1 to a variable or a contstant it does not matter
it still causes the same issue.
however if you are running this code in the same module it works fine. this only seems to appear when attempting to pass between 2 modules a negative number. |
|
Date |
User |
Action |
Args |
2019-05-10 03:15:16 | coldy028 | set | recipients:
+ coldy028, terry.reedy |
2019-05-10 03:15:16 | coldy028 | set | messageid: <1557458116.02.0.0587666073886.issue36872@roundup.psfhosted.org> |
2019-05-10 03:15:15 | coldy028 | link | issue36872 messages |
2019-05-10 03:15:15 | coldy028 | create | |
|