Need help with python variables and raw_input - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32) +---- Thread: Need help with python variables and raw_input (/showthread.php?tid=1148) |
Need help with python variables and raw_input - nevets04 - 10-11-2009 I there a way I can do something like: raw_input("Say something: ") The person would then type: Hello Is there a way to make x= the first letter(in this case h) y= the second letter(in this case e) And so on...? RE: Need help with python variables and raw_input - Gaijin - 10-11-2009 Yes try Code: t = raw_input("Type: ") RE: Need help with python variables and raw_input - L0iz - 10-11-2009 Yep the string slices: x = raw_input('Say something: ') Then we have variable x with string 'Hello'. Code: print x[0:1] Code: print x[1:2] Code: print x [2:3] If you then want variable y to be the second letter: Code: y = x[1:2] |