+ 5

Dear python programmers, help the stupid beginner!

-----------eng--------- Dear python programmers, help the stupid beginner! It is necessary that the 20th line would output the generated numbers not in a column, but in one line. How to do it? -------------rus----------- Дорогие программисты на питоне, помогите глупому новичку! Необходимо, чтобы 20-я строка выводила сгенерированные числа не в столбце, а в одну строку. Как это сделать? -------------code------------ 1. #Password generator 2.# This program was created to generate complex passwords 3.import random 4.# Hissing for the exit 5.def x (): 6. x = input ("\ tTo exit - press ENTER") 7.# Hype for exit end 8.#Alphabet 9.ABC = str ("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890") 10.start = input ("GENERATE PASSWORD? \ n:") 11.if start == "y": 12. num = (input ("How many characters should your password contain? \ n")) 13. print ("Password from" + num + "characters generated!") 14. print ("Result:") 15. high = len (ABC) 16. low = -len (ABC) 17. num = int (num) 18. for i in range (num): 19. pos = random.randrange (low, high) # Saves ABC [pos] 20. print (ABC [pos]) 21.print ("Write the result in a notepad and do not show it to anyone!") 22.x ()

9th Jan 2018, 10:13 PM
Elph From Tuspe
Elph From Tuspe - avatar
4 ответов
+ 5
Hello, of course you can When you wanna prevent to interpreter from making a new line after a print statement, use print("text goes here", end="") instead of a simple print By knowing that I'm sure you'll come to fix your issue :')
9th Jan 2018, 10:19 PM
Dapper Mink
Dapper Mink - avatar
+ 5
The end attribute is used to help you customise what you wanna end your printed stuff with. At default, end="\n" so gere, you can set end=""
9th Jan 2018, 10:29 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
20.print(ABC[pos], end="") 
9th Jan 2018, 10:18 PM
Mayor2k
Mayor2k - avatar
+ 2
----------ENGLISH----------- the default for "print" is to make a new line after print but you can adjust it by making: print(what you want to print out, end="what you want to end the print") ----------РУССКИЙ----------- по умолчанию для "print" это сделать новую линию после вывода на экран, но вы можете сменить это сделав это: print(что вы хотите чтобы было выводом, end="чем вы хотите окончить вывод")
10th Jan 2018, 2:21 AM
Leonid Iudakov