Try and remove any newline char that exist in the password
string.
You can do so using the following:
first_name = "david"
last_name = "s"
password = "\n1234"
print("firstname:",first_name)
print("lastname:",last_name)
print("password:",password)
# firstname: david
# lastname: s
# password:
# 1234
# removing the new line
password = password.replace("\n","")
print("firstname:",first_name)
print("lastname:",last_name)
print("password:",password)
# firstname: david
# lastname: s
# password: 1234
import re
re.sub("\n", "", password)
print("firstname:",first_name)
print("lastname:",last_name)
print("password:",password)
# firstname: david
# lastname: s
# password: 1234
The first option is using replace
method of string object which you can read about in the following link:
https://www.tutorialspoint.com/python/string_replace.htm
The second option is using sub
of the re
module which you can read about in the following link:
https://note.nkmk.me/en/python-str-replace-translate-re-sub/