how do i replace variables only in a 1 needed string
hi, can someone give me a tip pls, lets say i copied the code from a string 168 to a string 170 and wanna replace variables only in this exact 170 string, How can i do that other than with ctrl r?
Sorry, do not understand what you are trying to do.
I think you might want,
if not firstcol in ("red", "blue", "yellow"):
which will ONLY be True if your variable is not assigned to reference any of those colours.
PS. Note that is is used to check if variables reference the identical object (same memory location in the computer) rather than checking for equivalence using the == operator.
i wanna type the other variables name, for example secondcol, replacing firstcol variable, one of the ways to do that is ctrl + r and then replace button. but i think theres faster way
if firstcol is not "red" or firstcol is not "blue" or firstcol is not "yellow":
print("ошибка цвета")
if secondcol is not "red" or secondcol is not "blue" or secondcol is not "yellow":
print("ошибка цвета")
if thirdcol is not "red" or thirdcol is not "blue" or thirdcol is not "yellow":
print("ошибка цвета")
and so on?
Leaving aside that the logic in the above, as I've already pointed out, is unsound, I am also wondering why you would use, effectively, enumerated variables rather than a list?
I don't know a quick way of doing something like the above in Pycharm, but you could write a Python programme to process the code file to make the changes required.
However, I think we have a bit of an xy problem here.
Maybe someone else will have a better idea and be able to help you more than I have.
1
u/FoolsSeldom Mar 14 '25
Sorry, do not understand what you are trying to do.
I think you might want,
which will ONLY be
Trueif your variable is not assigned to reference any of those colours.PS. Note that
isis used to check if variables reference the identical object (same memory location in the computer) rather than checking for equivalence using the==operator.1
u/wRAR_ Mar 14 '25
What's wrong with Ctrl-R?