{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Want to join all leers the separator is the empty

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: o we need to modify the variables guess and copy, which are strings • However, string objects are immutable, so we must convert them to list objects CMPUT174  ­ ­ Design & Problem Solving 8 ConverBng strings to/from lists • ConverMng a string into a list: • Lists are mutable, which means we can modify them CMPUT174  ­ ­ Design & Problem Solving 9 3 13 ­10 ­02 ConverBng strings to/from lists • ConverMng a list of characters into a single string is done by “joining” all le<ers in the list to an exisMng string • Note that we need to provide a “separator”; if we just want to join all le<ers, the separator is the empty string! CMPUT174  ­ ­ Design & Problem Solving 10 ConverBng strings to/from lists • ConverMng a list of characters into a single string is done by “joining” all le<ers in the list to an exisMng string with the empty string as separator: • Replacing a le<er at a given posiMon CMPUT174  ­ ­ Design & Problem Solving 11 …Iterate and refine • Back to our problem: replacing posiMons in the secret code and the guess by markers “#”   Now using lists! CMPUT174  ­ ­ Design & Problem Solving 1...
View Full Document

{[ snackBarMessage ]}