Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Strip quotes and spaces from a variable

I want to create a variable [Word] that contains a word from a list of letters but does not include any brackets, spaces or commas.

Here’s where i have gotten to:

Letters = ["u", "i", "p","a","o","g", "h","j","k","l","z","x","v","b"]

FirstLetter = -1
SecondLetter = 'o'
ThirdLetter = 'a'
FourthLetter = 'l'
Endletter = 0
while FirstLetter < 13:
    FirstLetter = FirstLetter +1
    Word = (Letters[FirstLetter], SecondLetter,ThirdLetter,FourthLetter,Letters[Endletter])
    print(Word)

The output of the first line is: (‘u’, ‘o’, ‘a’, ‘l’, ‘u’)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want:

uoalu

Sorry if this is already answered I’ve tried a heap of suggestions on here but cant get it

>Solution :

If you want to join a string of characters into a single string, you should use join().

Word = "".join((
   Letters[FirstLetter], 
   SecondLetter,
   ThirdLetter,
   FourthLetter,
   Letters[Endletter],
 ))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading