简体   繁体   中英

How do I get the outputs to be in one row, instead of multiple? (Jupyter Notebook)

How do I get the outputs to be in one row, instead of multiple?

This is my code:

import random
Lu=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
Ll=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
N=['1','2','3','4','5','6','7','8','9']
S=['!','@','#','$','%','&','*']
def rp(num):
    for r in range(num):
        P1=random.choice(Lu)
        print(P1)
rp(10)

And this is the output:

U

J

K

W

Q

Q

T

O

V

R

import random
Lu=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
Ll=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
N=['1','2','3','4','5','6','7','8','9']
S=['!','@','#','$','%','&','*']
def rp(num):
    for r in range(num):
        P1=random.choice(Lu)
        print(P1 ,end = ' ')
rp(10)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM