Can someone tell me what is the difference between while(1) and while (true) in python?

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

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
'''

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

Filter only letters from string.

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.

what does this mean ord(a) - 97?

>>> 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.