To generate random characters

Hi..today i learnt how to generate  the ranom charecters in python..

As per the ascii type starts with range 32 to 126. use any variable for iteration..

>>> for i in xrange(32, 127):
…    print chr(i),
...
  ! ” # $ % & ‘ ( ) * + , – . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~

if you don’t want space means start at 33.

 

string conversion

Hi..today i learnt how to convert string to code.instead for getting input from user everytime and placing into a variable...follow this... (e.x) a to z or 1 to 26 variables..

>>> vars = {}
>>> for x in xrange(26):
...  vars[x] = ''
...
>>> for x in xrange(26):
...  vars[x] = raw_input("What is %s? " % x)
...
>>> print vars

{0: ‘a’, 1: ‘b’, 2: ‘c’, 3: ‘d’, 4: ‘e’, 5: ‘f’, 6: ‘g’, 7: ‘h’, 8: ‘i’, 9: ‘j’, 10: ‘k’, 11: ‘l’, 12: ‘m’, 13: ‘n’, 14: ‘o’, 15: ‘p’, 16: ‘q’, 17: ‘r’, 18: ‘s’, 19: ‘t’, 20: ‘u’, 21: ‘v’, 22: ‘w’, 23: ‘x’, 24: ‘y’, 25: ‘z’}
>>>