@aerossss

IndentationError: unexpected unindent что делать?

Код
from tkinter import *

root = Tk()
root.geometry("265x400")
root.title("Калькулятор для Тани")
root.config(background="lightblue")

expresion = ""

result = StringVar()
expersion_field = Entry(textvariable=result)
expersion_field.grid(columnspan=4, ipadx=70)

def pressnum(num):
    global expresion
    expresion += str(num)
    result.set(expresion)

def equalpress():
    try:
        global expresion
        total = str(eval(expresion))
        result.set(total)
        expresion = total

def converter(num):
    global expresion
    total = str(eval(expresion) * num)
    result.set(total)
    expresion = total




button1 = Button(text = "1", height= 1, width= 7, command = lambda: pressnum(1))
button1.grid(row = 2, column = 0)

button2 = Button(text = "2", height= 1, width= 7, command = lambda: pressnum(2))
button2.grid(row = 2, column = 1)

button3 = Button(text = "3", height= 1, width= 7, command = lambda: pressnum(3))
button3.grid(row = 2, column = 2)

button4 = Button(text = "4", height= 1, width= 7, command = lambda: pressnum(4))
button4.grid(row = 3, column = 0)

button5 = Button(text = "5", height= 1, width= 7, command = lambda: pressnum(5))
button5.grid(row = 3, column = 1)

button6 = Button(text = "6", height= 1, width= 7, command = lambda: pressnum(6))
button6.grid(row = 3, column = 2)

button7 = Button(text = "7", height= 1, width= 7, command = lambda: pressnum(7))
button7.grid(row = 4, column = 0)

button8 = Button(text = "8", height= 1, width= 7, command = lambda: pressnum(8))
button8.grid(row = 4, column = 1)

button9 = Button(text = "9", height= 1, width= 7, command = lambda: pressnum(9))
button9.grid(row = 4, column = 2)

minus = Button(text = "-", height= 1, width= 7, command = lambda: pressnum("-"))
minus.grid(row = 5, column = 2)

button0 = Button(text = "0", height= 1, width= 7, command = lambda: pressnum(0))
button0.grid(row = 5, column = 1)

plus = Button(text = "+", height= 1, width= 7, command = lambda: pressnum("+"))
plus.grid(row = 5, column = 0)

equal = Button(text = "=", height= 1, width= 7, command = equalpress)
equal.grid(row = 6, column = 1)

umn = Button(text = "*", height= 1, width= 7, command = lambda: pressnum("*"))
umn.grid(row = 6, column = 2)

dele = Button(text = "/", height= 1, width= 7, command = lambda: pressnum("/"))
dele.grid(row = 6, column = 0)

rub_to_doll = Button(text = "RTD", height= 1, width= 7, command=lambda: converter(0.02))
rub_to_doll.grid(row = 7, column = 0)


весь код но ошибка показывает тут

def converter(num):
    global expresion
    total = str(eval(expresion) * num)
    result.set(total)
    expresion = total
  • Вопрос задан
  • 85 просмотров
Решения вопроса 1
Lord_of_Rings
@Lord_of_Rings
Python developer
def equalpress():
    try:
        global expresion
        total = str(eval(expresion))
        result.set(total)
        expresion = total
    except:
        pass
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы