No code from me, because I have no idea what to do! :P
I'm trying to build a password generator.
Hope you guys can help.
No code from me, because I have no idea what to do! :P
I'm trying to build a password generator.
Hope you guys can help.
A concise, practical answer for : in Python you usually convert between numbers and characters with the built‑ins chr() and ord() (the Python equivalents of a cast in C — thanks for the idea) or by working with bytes when you need exact 0–255 byte values. List comprehensions or generator expressions replace a manual loop (as suggested) and are clearer and faster.
A few snippets that apply directly (Python 3):
Convert a list of integers to a text string:
nums = [65, 66, 67]
text = ''.join(chr(n) for n in nums) Convert text back to numeric code points:
nums = [ord(c) for c in text] If you must work with raw bytes (0–255) use bytes() and decode explicitly (use a single‑byte codec like Latin‑1 to preserve values 0–255):
b = bytes([65, 66, 67])
text = b.decode('latin-1') For password generation pick a safe character set and a cryptographically secure RNG. Prefer the secrets module over random for secrets:
import secrets, string
alphabet = string.ascii_letters + string.digits + string.punctuation
pwd = ''.join(secrets.choice(alphabet) for _ in range(12)) Notes and cautions: ord()/chr() work with Unicode code points (not limited to 0–255), while bytes([...]) requires values 0–255. If you need printable-only characters use string.printable or build a custom set. Also consider which encoding you will store/transmit the password in to avoid surprises with non-ASCII characters.
See the Python docs for chr()/ord() and bytes, and use secrets for generating passwords: chr()/ord documentation, bytes type, secrets module.
Jump to Post— LizR 171As long as the numbers represent numbers within the ascii range... eg 1-255 etc
int i = 65;
char c = (char) i; // This gives 'A'
As long as the numbers represent numbers within the ascii range... eg 1-255 etc
By series of numbers, i assume its an array..
i guess theres no way but to use a for loop and type cast the number and put it in a string.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.