I am trying to make a function to iterate over the list. Can anyone let me know and explain that what t is that I am doing wrong?
iplist = ['1.1.1.1', '2.2.2.2', '3.3.3.3', '4.4.4.4']
def ip_addr(addr_list):
for ip_addresses in addr_list:
return ip_addresses
test = ip_addr(iplist)
print(test)
I am expecting output:
1.1.1.1
2.2.2.2
3.3.3.3
4.4.4.4
However, I am getting the following output:
1.1.1.1
Thanks,
returnends the function, and therefore breaks the for-loopreturn ip_addresswithprint(ip_address)? All your function does is loop over the list anywayprintis not going to allowtestto be set as desired.