and thanks in advance. I am working on a program, and during it, I am allowing for the change of some connections within the program itself. As such, I wrote the following code to facilitate this:
n = {'car': 'gate'} #this also exists for all the other directions
directions = ['n', 's', 'e', 'w', 'ne', 'nw', 'sw', 'se', 'u', 'd']
roomto = input("\nROOM TO CHANGE CONNECTIONS FOR (A) # ").lower()
toroom = input("\nROOM IT SHOULD LEAD TO (B) #").lower()
toroomd = input("\nWHAT DIRECTION SHOULD LEAD FROM A TO B? # ").lower()
toroomb = input("\nWHAT DIRECTION SHOULD LEAD FROM B TO A? # ").lower()
if(toroomd in directions) and (toroomb in directions):
statusd = 'status' + toroomd
statusb = 'status' + toroomb
toroomd[roomto] = toroomd
toroomb[toroom] = roomto
print("Success!")
However, it gives me the following error (ignore the line number, that's just where it is in the larger program):
TrTraceback (most recent call last):
File "python", line 1885, in <module>
TypeError: 'str' object does not support item assignment
I have read a bit, and have tried to wrap the toroomd[roomto] = toroomd in a list, but that just gives me a new error about list cant being around a str and having to be around a float or a splice.
Any suggestions, or is this just not possible?