Python beginner's question! String variable, function use question 00ㅠ

Asked 2 years ago, Updated 2 years ago, 15 views

I understand that the already declared string cannot be modified. So, I learned that I have to bind a new object to a new variable and print it out (So in the upper problem, ticker1 newly bind and output the function)

However, the next problem is that we have already bound a new variable to an object that binds a string variable and outputs a function, so is there no problem in the task of declaring an object that has previously bound?

I'm confused.

python

2022-09-20 11:08

1 Answers

No problem at all. You can see it by running the process of redefining the value of the string directly.

ticker = "btc_krw"

ticker = ticker.upper()
print(ticker) # "BTC_KRW"

ticker = ticker.lower()
print(ticker) # "btc_krw"

If you run the code above, you can reallocate multiple times with one ticker without creating additional variables. You can reassign the value unless the original data must be retained.


2022-09-20 11:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.