0

I am trying to print the primary catchall but every time I do it it returns one character per line, how do I make it so it prints the whole catchall in one line.

Result:

@
g
m
a
i
l
.
c
o
m

Expected result: @gmail.com

JSON Code:

{
    "primaryCatchall": "@gmail.com",
    "secondaryCatchall": "@gmail.com",
    "password": "password123",
    "repeat": 5
}

Python code:

import json

with open('tempemail.txt', 'r') as myfile1:
    email1 = myfile1.read()
    with open('config.json', 'r') as config:
        PrimaryCatchall = json.load(config)
    for primaryCatchall in PrimaryCatchall['primaryCatchall']:
        with open('accounts.txt', 'a') as accounts:
            print(primaryCatchall)
            #accounts.write("\n")
            #accounts.write(email1)
            #accounts.write(primaryCatchall)
503ryan
  • 29
  • 3
  • Hi 503ryan, this has already been answered here https://stackoverflow.com/questions/3249524/print-in-one-line-dynamically you just need to update `print(primaryCatchall)` to `print(primaryCatchall, end="")` if you're using Python 3 – zzarbi May 29 '20 at 01:25

1 Answers1

2

In your code, you loaded your JSON as the variable PrimaryCatchall. Right afterward, you ran a for loop for PrimaryCatchall, which got each individual character. Get rid of that for loop to fix the problem

twiddler
  • 588
  • 4
  • 16