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)
1
  • Hi 503ryan, this has already been answered here stackoverflow.com/questions/3249524/… you just need to update print(primaryCatchall) to print(primaryCatchall, end="") if you're using Python 3 Commented May 29, 2020 at 1:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.