Python Forum
little problem with read out and write into a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
little problem with read out and write into a file
#11
yea found it now but there is still a problem...... "zwischenschritt isn't defined and I have no idea how to do that because I just copy and paste the code from above so I have nooooooo idea could you guys explain to me how to do that? Good thing is it runs but only until line 19.

main = 1
behebung = 0
rechnung_kontostand = 0
ergebniss_kontostand = 0
ergebniss_kontostand2 = ""
while main == 1:
	main = 0
	print("Möchten Sie \n 1) Beheben \n 2) Einzahlen \n 3) Kontostand \n 4) Bewegungen \n 5) beenden")
	auswahl = input()

	
	if auswahl == "1":
		behebung = 1
		while behebung == 1:
			behebung = 0
			behebung_auswahl = input("Wieviel möchten Sie beheben?\n 1)50€ \t \t \t \t 2)100€ \n 3)200€ \t \t \t \t 4)500€ \n 5)800€ \t \t \t \t 6)1000€ \n")
			with open("kontostand.txt") as fin:
				for line in fin.readlines():
					rechnung_kontostand = int(zwischenschritt)
					if auslesen_kontostand == "":
						print("Sie haben kein Konto!")
						behebung = 0
						main = 1

			if auslesen_kontostand != "":
		
				if behebung_auswahl == "1" and rechnung_kontostand >= -2250:
					ergebniss_kontostand = rechnung_kontostand - 50
					ergebniss_kontostand2 = str(ergebniss_kontostand)
					print("Entnehmen Sie Ihre 50€")
					auslesen_kontostand = open("kontostand.txt", "w")
					with open("kontostand.txt", "w") as f:
						f.write(ergebniss_kontostand2)
						main = 1

		
	if auswahl == "5":
		main = 0
		print("Bis zum nächsten mal!")

	if auswahl != "1" and auswahl != "2" and auswahl != "3" and auswahl != "4" and auswahl != "5":
		print("Bitte geben Sie eine gültige Operation ein!")
		main = 1
Reply
#12
I saw that previous time.  I was thinking that that is not all of the code. Can't help here because don't know where it comes from. Obviously, it contains a string which has to be converted to an integer. It could be '4' but also '5555555555'.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  UART Serial Read & Write to MP3 Player Doesn't Work bill_z 16 5,640 14 minutes ago
Last Post: Ronaldweera
  Last record in file doesn't write to newline gonksoup 3 364 Jan-22-2024, 12:56 PM
Last Post: deanhystad
  Recommended way to read/create PDF file? Winfried 3 2,783 Nov-26-2023, 07:51 AM
Last Post: Pedroski55
  write to csv file problem jacksfrustration 11 1,371 Nov-09-2023, 01:56 PM
Last Post: deanhystad
  python Read each xlsx file and write it into csv with pipe delimiter mg24 4 1,308 Nov-09-2023, 10:56 AM
Last Post: mg24
Question Special Characters read-write Prisonfeed 1 581 Sep-17-2023, 08:26 PM
Last Post: Gribouillis
  read file txt on my pc to telegram bot api Tupa 0 1,048 Jul-06-2023, 01:52 AM
Last Post: Tupa
  parse/read from file seperated by dots giovanne 5 1,043 Jun-26-2023, 12:26 PM
Last Post: DeaD_EyE
  Formatting a date time string read from a csv file DosAtPython 5 1,160 Jun-19-2023, 02:12 PM
Last Post: DosAtPython
  How do I read and write a binary file in Python? blackears 6 6,011 Jun-06-2023, 06:37 PM
Last Post: rajeshgk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020