Hier ist mein Code. Ich verstehe nicht, warum ich diesen Fehler bekomme und wie ich ihn korrigiere. Der Fehler tritt auf: totals = entrant + float(tot)
hier ist mein vollständiger Code:Wert Fehler: konnte STR nicht in Float konvertieren PYTHON
def total():
File = open("argent.txt","r")
File = File.read()
tot = File
print("You have",tot,"£ in your account")
def add():
entrant = float(input("How many do you want to add to your account? "))
with open("argent.txt", 'r') as f:
tot = f.read().rstrip('\n')
print("You have ",tot,"£ in your account")
totals = entrant + float(tot)
print(totals)
with open("argent.txt", 'w') as f:
output = str(totals)
f.write(output)
add()
Vielen Dank im Voraus.
'tot' Datei keine gültige Schwimmer ist – Li357
eine Probe Ihres Dateiinhalt Bereitstellung oder die' print' Aussage über – praba230890
die Datei nur ein Textdatei mit 20 in der ersten Zeile. –