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
  How can I write formatted (i.e. bold, italic, change font size, etc.) text to a file? JohnJSal 12 27,767 Feb-13-2025, 04:48 AM
Last Post: tomhansky
  How to write variable in a python file then import it in another python file? tatahuft 4 846 Jan-01-2025, 12:18 AM
Last Post: Skaperen
  How to read a file as binary or hex "string" so that I can do regex search? tatahuft 3 980 Dec-19-2024, 11:57 AM
Last Post: snippsat
  [SOLVED] [Linux] Write file and change owner? Winfried 6 1,460 Oct-17-2024, 01:15 AM
Last Post: Winfried
  python read PDF Statement and write it into excel mg24 1 928 Sep-22-2024, 11:42 AM
Last Post: Pedroski55
  Read TXT file in Pandas and save to Parquet zinho 2 1,196 Sep-15-2024, 06:14 PM
Last Post: zinho
  Pycharm can't read file Genericgamemaker 5 1,511 Jul-24-2024, 08:10 PM
Last Post: deanhystad
  Python is unable to read file Genericgamemaker 13 3,458 Jul-19-2024, 06:42 PM
Last Post: snippsat
  Delete file with read-only permission, but write permission to parent folder cubei 6 25,205 Jun-01-2024, 07:22 AM
Last Post: Eleanorreo
  Connecting to Remote Server to read contents of a file ChaitanyaSharma 1 3,138 May-03-2024, 07:23 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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