so I'm trying to change the data that the user enters through the form into a string.
this is the code for the combobox
Status_bangunan_cb = Combobox(window, textvariable = STATUS_BANGUNAN,values=['1. Milik Sendiri','2. Kontrak/Sewa','3. Bebas Sewa','4. Dinas','5. Lainnya'],
font=14,state='r',width=33).place(x=320,y=110)
and here is the output
1. Milik Sendiri
but the output i want is 1, so the previous user input is converted to a number.
I have tried using the following code
Status_bangunan.replace({'1. Milik Sendiri':1,'2. Kontrak/Sewa':2,'3. Bebas Sewa':3,'4. Dinas':4,'5. Lainnya':5}, inplace=True)
but it doesn't work, and here is the error
TypeError: str.replace() takes no keyword arguments
then I also tried the following code
SB = Status_bangunan.replace('1. Milik Sendiri','1')
the result
1
the code works but only for 1 part, what I want is for all of them to be automatically converted not just 1. but str.replace() function only for 2 arguments.
the result that I expect is that when the user inputs through the form (categorical) the results obtained will be automatically converted to numbers
I'm still confused about this, please help. for the form I use python gui
i have tried this code
Dict1 = {"1. Milik Sendiri":"1", "2. Kontrak/Sewa":"2","3. Bebas Sewa":"3","4. Dinas":"4","5. Lainnya":"5"}
for key in Dict1.keys():
SB = Status_bangunan.replace(key, Dict1[key])
but the result
1. Milik Sendiri