P
P
puffyq2020-07-15 12:36:28
Python
puffyq, 2020-07-15 12:36:28

Dynamic variable?

a = 123
b = 'asd'
ab = a + b
while a > 0:
    a = a - 1
print(a)

How to write the variable "a" so that it can change dynamically during the loop and the variable "ab" can be executed. Is it possible to write the same "a" as a list so that it does not conflict with str and can change dynamically?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FinGanapre, 2020-07-15
@FinGanapre

Didn't quite understand what you are trying to implement... look at the output, maybe something like that.

a = 123
b = 'asd'
ab = str(a) + b
list = []
while a > 0:
  a -= 1
  ab = str(a) + b
  list.append(ab)
  print(a)
  print(ab)
  print(list)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question