0
import string
numbers = []
unencrypted_pass = input(str("Place your password here:"))
encrypt_1 = unencrypted_pass [::-1]
alphabet_up = string.ascii_uppercase
alphabet_low = string.ascii_lowercase
for letter in encrypt_1:
    number = ord(letter) - 96
    numbers.append(number)
print(numbers)

I'm trying to remove the commas between the numbers in the variable "numbers" like this: [20, 1, 5, 8] --> 20158.

node_0
  • 1
  • simply do this `print(','.join(str(x) for x in numbers))` – A l w a y s S u n n y Mar 14 '21 at 14:34
  • You cannot "remove the commas between the numbers in the variable", because the variable doesn't contain commas, and because numbers don't have things between them. `[20, 1, 5, 8]` is a *representation of* the list. What you are trying to do is *create a string* that *contains the text representations of* the numbers, concatenated together without commas in between. – Karl Knechtel Mar 14 '21 at 14:35
  • For future questions, I recommend creating a minimal reproducible example. For this question, we don't need the background of passwords and encryption and string functions. Your question could have been simplified to -> I have a list of integers and want to remove the comments to get a single number. `numbers = [20,1,5,8]` expected output `20158` – user1558604 Mar 14 '21 at 14:36
  • But you should think carefully about what you really want. It seems like you want to be able to get the original string back. Think carefully: if you get the result `"21"`, and want to figure out what the original password text was, should it be `"ba"`, or should it be `"u"`? Why? How can you tell? – Karl Knechtel Mar 14 '21 at 14:37

1 Answers1

1
list1 = [20, 1, 5, 8]
str1 = ''.join(str(e) for e in list1)
print(str1)

output

20158