Posts
-
who is your favourite browsedns user -
Help WantedHi! I kinda wanna try to make a social network... any willing?
-
Y'know what they say!@SupearMan Y TF IS SANS IN THERE????

-
can someone give me some tips on how to make Python programs that write data to external files?@danniltrifonov Yeah and chat gpt cant even write code. it can just correct code
-
can someone give me some tips on how to make Python programs that write data to external files?@Andyboi yeah actually but he sometimes is outdated so its better to just check the forms
-
can someone give me some tips on how to make Python programs that write data to external files?@danniltrifonov You're welcome!
-
can someone give me some tips on how to make Python programs that write data to external files?Hope it worked :)
-
can someone give me some tips on how to make Python programs that write data to external files?1. Wrong logic in
is_minor()You wrote:
if age > 18: is_minor = True else: is_minor = FalseThis means someone over 18 is considered a minor, which is backwards.
It should be:if age < 18: is_minor = True else: is_minor = FalseOr even shorter:
return age < 18
2. Missing parenthesis in
file.write()In
write_to_file():file.write(name + ", "You forgot the closing
)for thatfile.writecall.
3. Writing a boolean directly to a file
file.write()needs a string.
You’re trying to write:file.write(minor)But
minoris a boolean (TrueorFalse). You must convert it to string:file.write(str(minor))
4. You’re opening the file with
r+r+means read/write without truncating. If the file doesn’t exist, it will throw an error. If you just want to append, use"a"or"a+". If you want to overwrite, use"w".
Fixed Code
Here’s a working version:
# Open in append mode file = open("database.txt", "a") name = input("Enter your name: ") age = int(input("Enter your age: ")) def is_minor(age): return age < 18 minor = is_minor(age) def write_to_file(name, age, file, minor): file.write(name + ", ") file.write(str(age) + ", ") file.write(str(minor) + "\n") write_to_file(name, age, file, minor) file.close() -
🤡Do you ever miss just joking around? clowning on people or just having a gang?? Well look no further than this:
The Party_Clowns!
we (by wich i mean me) are a group of people who just wanna break free from hours of boredom and start doing stupid stupidity around! of course we won't break any rules and such but we will have lots of fun.This is NOT against the rules since this is small advertising and not spammed or botted.
-
Act along the thing@lewcyyi NO ITS NOT GET BACK HERE
-
Act along the thing -
Act along the thingnever actually did the deed but he hurted them a lot
-
Act along the thing@Apollo.Is.Silly yeah he kinda did. he used to hump small puppies
-
Act along the thing -
Act along the thing@Apollo.Is.Silly he died in a car acident after drinking my dad's beer that fell on the floor :((
-
Act along the thing@Apollo.Is.Silly dang i had a pet golden retriever
-
Act along the thingYOU KNOW WHAT IMMA JOIN YOU (^v^)
BARK BARK!! Runs after tail
-
Act along the thingAHHGHH NARR MY PLAN FAILED SINCE UR TOO BELOVED TO BE PRANKEDDDD :(
-
Act along the thingDROP ON UR KNEES AND BARK LIKE U WANT IT (lol)