4
Contributors
7
Replies
8
Views
4 Years
Discussion Span
Last Post by pyTony
0

Latter causes uninitialized variable error if true variable is not defined. Python is case sensitive.

0

Please use True (it is capitalized) ...

# initialize count
count = 0
# you could use 1 instead of True, but True is clearer
while True:
    print(count)
    count += 1
    # exit condition needed to stop endless loop
    if count > 8:
        break

'''result ...
0
1
2
3
4
5
6
7
8
'''

Edited by vegaseat

0

ok can you tell me what does this mean :
string = ''.join(c for c in string if c.isalpha()) ?

0

The generator expression says, return a list of characters for every alphabetical character in string. The .join() method (applied to an empty string, and taking the generated list as it's argument) then fuses the list elements into a new string, with no separator character between them. The practical upshot of it is to filter out any character in string that isn't a letter.

0
>>> chr(97)
'a'

So look like you are desiphering code dealing with number of letter in alphabet, probably Caesar "crypto" Actually your references to code look similar to my code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.