Variable update question

Hello guys. I would like someone to explain why I can’t update the variable “LN”, which is outside the while loop, through an update of itself that occurs in that loop. Below is the code:

Dados_Mat = int(input('Informe o Fck do concreto em MPa: ')), int(input('Informe o Fyk do
aço em MPa: ')), float(input('Informe a bitola da armadura longitudinal em mm: ')),
int(input('Informe a quantidade de barras que compõem a armadura longitudinal: '))
Dados_Sec = float(input('Informe o valor da menor dimensão da seção em metros: ')),
float(input('Informe o valor da maior dimensão da seção em metros: ')),
float(input('Informe o valor do desconto da maior dimensão em metros: '))
Aaco = ((3.14159 * ((Dados_Mat[2] / 1000) ** 2)) / 4) * Dados_Mat[3]
Faco = Aaco * (Dados_Mat[1] * 10 ** 6)
Tconc = 0.85 * ((Dados_Mat[0] * 10 ** 6) / 1.4)
LN = 0
Fcon = Tconc * Dados_Sec[0] * 0.8 * LN
if Fcon < Faco:
cont = 0
while cont == 0:
LN += 0.01
Aaco = ((3.14159 * ((Dados_Mat[2] / 1000) ** 2)) / 4) * Dados_Mat[3]
Faco = Aaco * (Dados_Mat[1] * 10 ** 6)
Tconc = 0.85 * ((Dados_Mat[0] * 10 ** 6) / 1.4)
Fcon = Tconc * Dados_Sec[0] * 0.8 * LN
if Fcon == Faco:
cont += 1
print(LN)

Bem Vindo, Dr Herbet.

Will you please edit your post by…?

  1. Highlighting the code
  2. Selecting the ‘</>’ button in the format toolbar at the top of the editor. It’s to the left of center.
  3. Re-pasting the code from your Python editor, to put the indents back in.

If you “fence” the pasted code as shown below (with ``` backticks) , it will also add colors:

```python
<code goes here>
```

print("Bem Vindo! Muitu melhor!!")

Please see my previous post about formatting posted code.

I separated your input() lines to make them easier to read and the program looked like it works as you intend. The code in your original post is not the code you’re running because the posted code is cut into lines from word wrapping. Please use the code formatting function to make sure your posted code is the same as the code in your editor.

Using inputs of 1, 2, 3, 4, 5 ,6, 7 the LN values printed are:

13.389999999999759
13.399999999999759
13.409999999999759
13.419999999999758
13.429999999999758

Here is the code I ran. (NOTE: I had to guess on the indentation of the two IF: clauses and the WHEN: clause because the original code was not formatted.)

Dados_Mat = int(input('Informe o Fck do concreto em MPa: ')), \
            int(input('Informe o Fyk doaço em MPa: ')), \
            float(input('Informe a bitola da armadura longitudinal em mm: ')), \
            int(input('Informe a quantidade de barras que compõem a armadura longitudinal: '))
Dados_Sec = float(input('Informe o valor da menor dimensão da seção em metros: ')), \
            float(input('Informe o valor da maior dimensão da seção em metros: ')), \
            float(input('Informe o valor do desconto da maior dimensão em metros: '))
Aaco = ((3.14159 * ((Dados_Mat[2] / 1000) ** 2)) / 4) * Dados_Mat[3]
Faco = Aaco * (Dados_Mat[1] * 10 ** 6)
Tconc = 0.85 * ((Dados_Mat[0] * 10 ** 6) / 1.4)
LN = 0
Fcon = Tconc * Dados_Sec[0] * 0.8 * LN
if Fcon < Faco:
    cont = 0
while cont == 0:
    LN += 0.01
    Aaco = ((3.14159 * ((Dados_Mat[2] / 1000) ** 2)) / 4) * Dados_Mat[3]
    Faco = Aaco * (Dados_Mat[1] * 10 ** 6)
    Tconc = 0.85 * ((Dados_Mat[0] * 10 ** 6) / 1.4)
    Fcon = Tconc * Dados_Sec[0] * 0.8 * LN
    if Fcon == Faco:
        cont += 1
    print(LN)