Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with python variables and raw_input
#3
Yep the string slices:

x = raw_input('Say something: ')

Then we have variable x with string 'Hello'.

Code:
print x[0:1]
'H'
Code:
print x[1:2]
'e'
Code:
print x [2:3]
'l'

If you then want variable y to be the second letter:

Code:
y = x[1:2]
Reply


Messages In This Thread
RE: Need help with python variables and raw_input - by L0iz - 10-11-2009, 12:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 2,009 09-30-2019, 12:59 AM
Last Post: samsmith001
  Simple Python Python Compiler Canoris 21 9,215 06-01-2011, 06:30 PM
Last Post: Filefinder
  Python 2 vs 3? Jake 8 2,670 12-11-2010, 04:13 PM
Last Post: Bursihido
  Python help Kharnage 2 904 02-12-2010, 09:07 PM
Last Post: Kharnage
  "==" and "is" in Python Canoris 1 852 02-07-2010, 03:55 PM
Last Post: uber1337

Forum Jump:


Users browsing this thread: 1 Guest(s)