#๐ creating a connections between 2 keys in a dictionary
26 messages ยท Page 1 of 1 (latest)
@autumn stump
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
does anyone know how to basically link a key to another key in a dictionary?
rn my code basically ask for a server and ip and puts in a list
same serrver name and ip and you want that in a dict?
and im trying to make another function that basically connects one server to another with a ping
wdym
rtr_dict = {servername}: {ip}}
or add both at once with a , after the first dict.. your familiar with dicts?
so you connect to one rtr and just call the 2nds ip..rtr/server.. whateva
yeah i want to basically connect the ips in both directions to each other so server1 to server 2 and 2 to 1
but im wondering how i should get to that point
this matters because for my other functions i need to be able to do this
this part should be easy once i can figure out the dictonary design
2 python scripts running on 2 diffetent servers.. you should just assign the ips in the dict and use the name from the dict to access the other.. I think your over complicating it unless your trying to do this dynamically
typically you would do host:ip in the dict.. if you have a dict fullnof hosts, and the starting point is yoir issue then you just need to get the hostname or ip of the server it starts on to be able to exclude it from selecting the same again
by assign the ips in the dict, do you mean like making a list or dict within a value?
also we nee to be able to do this during the traceroute
servers = {
"Server1": "192.168.1.10",
"Server2": "192.168.1.11",
"Server3": "192.168.1.12",
"Server4": "192.168.1.13",
"Server5": "192.168.1.14"
}
for server, ip in servers.items():
#do your traceroute
i cant use builtins so i dont think items can be used
then make it a list of ips.. this is sounding like homework now.. dunno if i have the time tonight to explain each step you need to do... but where you at and whats next
it fine then ill try to find another way to do it.
if you need both name and ip.. list of tuples
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.