Detect the input number of signs in python and use it in a loop for encryption
<p>I am writing a very easy encryption program. I just shift the ASCII order number of a sign with a key. My code looks as following:</p>

<pre><code>#Type in sign or text and key
clear_text = input("Text? ")
key = int(input("Key? "))

# saves ASCII order number of the sign
ord_number = ord(clear_text)

#shift ASCII odernumber with the key -&gt; encryption
shift_ord_number = ord_number + key
key_ord_number = chr(shift_ord_number)
print(key_ord_number)
</code></pre>

<p>I want to advance this code by being able to type in a whole sentence. For this I somehow must detect how many signs the user has typed in. How would that be possible? And what loops would you recommend?</p>

<p>You want to use a string for your sentence, from which you can extract individual characters to do your encryption on.  In fact, <code>clear_text</code> is already a string, but (presumably) since you only entered a single character, it is only 1 character long.</p>

<p>To get the length of a string, you can use <code>len(clear_text)</code>.  You can also iterate over the characters of a string using </p>

<pre><code>for char in clear_text:
    ord_number = ord(char)
    shift_ord_number = ord_number + key
    key_ord_number = chr(shift_ord_number)
    print(key_ord_number)
</code></pre>

python