#๐Ÿ”’ The console just stops working, i am doing something wrong

27 messages ยท Page 1 of 1 (latest)

terse dagger
#

import random

class Persona:
def init(self, nombre, apellido):
self.nombre = nombre
self.apellido = apellido

class Cliente(Persona):
def init(self, numero_cuenta, balance):
self.numero_cuenta = numero_cuenta
self.balance = balance

nombres_legales_persona = Persona('', '')
balance_cuenta = Cliente(random.randint(1000000, 9999999), '')
balance_cuenta.balance = 0
eleccion_menu = 0
finalizar_programa = False

def Registro():
nombres_legales_persona.nombre = input(f'Bienvenido al Banco Lacra!, Vamos a Registrarte \n Digita Tu nombre: ')
nombres_legales_persona.apellido = input(f'Digita tu Apellido: ')
return nombres_legales_persona

def depositar():
deposito = int(input('Digita el monto a depositar'))
balance_cuenta.balance = deposito + balance_cuenta.balance
return balance_cuenta

def estado_de_cuenta():
print(f"""Este es el estado de su cuenta:
Nombre Completo: {nombres_legales_persona.nombre} {nombres_legales_persona.apellido}
Numero De Cuenta: {balance_cuenta.numero_cuenta}
Monto Disponible: {balance_cuenta.balance}""")

def Retirar():
deposito = int(input('Digita el monto a retirar'))
balance_cuenta.balance = deposito - balance_cuenta.balance
return balance_cuenta

def menu():
print("Elige una opcion:")
print('''
[1] - Consultar Estado de cuenta
[2] - Depositar
[3] - Retirar
[4] - Salir''')
eleccion_menu = int(input())
return eleccion_menu

Registro()
estado_de_cuenta()
menu()

while not finalizar_programa:
if eleccion_menu == 1:
estado_de_cuenta()
x = input('Digita cualquier tecla para continuar')
menu()
elif eleccion_menu == 2:
depositar()
menu()
elif eleccion_menu == 3:
Retirar()
menu()
elif eleccion_menu == 4:
finalizar_programa = True

there is a problem with my code, please help me

placid orbitBOT
#

Hey @terse dagger!

It looks like you are trying to paste code into this channel.

You seem to be using the wrong symbols to indicate where the code block should start. The correct symbols would be ```, not """.

Here is an example of how it should look:
```
Hello, world!
```

This will result in the following:

Hello, world!```
You can **edit your original message** to correct your code block.
#

@terse dagger

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

proper parrot
#

What exactly happens?

terse dagger
#

there is a menu

#

and there are 4 options

#

but when i try to pick a option

#

the code just stops working

proper parrot
#

You return eleccion_menu from the menu() function, but you never set it in the outer code

#

You need to do eleccion_menu = menu() if you want to define it as the menu function's return value

terse dagger
#

i dont get it

#

after or before using the funcion

#

?

#

sorry for my bad english :,v

proper parrot
#

When using the function

#

Do you know how return works?

#

!print-and

placid orbitBOT
#
Print and return

Here's a handy animation demonstrating how print and return differ in behavior.

See also: /tag return

terse dagger
#

ohhh

#

i get it

#

let me try again

#

i dont know what im doing wrong

#

ohh wait

#

i figured it out thanks to u

terse dagger
placid orbitBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.