Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,147 members, 7,818,447 topics. Date: Sunday, 05 May 2024 at 04:02 PM

Python Exercise - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Exercise (1096 Views)

I Need Help With This Python Exercise / INEC Voter Registration Exercise- IT Analysis (2) (3) (4)

(1) (Reply) (Go Down)

Python Exercise by Nobody: 10:40pm On Oct 06, 2012
Hello gurus in the house.. Please any idea on how i can interchange the first and last letters of any word using python?
.
.
E.g
.
'good' = 'doog'
'soup' = 'pous'
'given' = 'niveg'
.
.
Was thinking of using 'slice' - it didn't work. Help me out..
Just give me tips on how to go about it..don't write the program for me please.. Thanks in advance..
Re: Python Exercise by Nobody: 12:51pm On Oct 07, 2012
x="good"
print(x[-1]+x[1:-1]+x[0])

since strings are lists in python

x[-1] take the last character, minus means "start counting from the last character"
x[1:-1] selects from second character to penultimate inclusive, note that index starts from zero
x[0] is the first character
Re: Python Exercise by Nobody: 4:44pm On Oct 07, 2012
webdezzi:

since strings are lists in python

x[-1] take the last character, minus means "start counting from the last character"
x[1:-1] selects from second character to penultimate inclusive, note that index starts from zero
x[0] is the first character

thanks man, I really appreciate it..
Hope you don't mind answering another question?
Do you have any idea on how I can make PyGTK work on Windows? I've installed it, yet it's not working.(I tried using PyQt, but there is no good book on it).
Re: Python Exercise by Nobody: 5:28pm On Oct 07, 2012
.
Re: Python Exercise by Nobody: 10:46pm On Oct 07, 2012
i've never used gtk,
the debate is usually btw wx and Qt and not gtk

there are billions on Qt tutorials online, especially on youtube
Re: Python Exercise by Nobody: 10:40am On Oct 08, 2012
webdezzi: i've never used gtk,
the debate is usually btw wx and Qt and not gtk

there are billions on Qt tutorials online, especially on youtube
thanks man.
ok..
Re: Python Exercise by vokah0907: 8:14am On Oct 11, 2012
Hope you don't mind answering another question?[img]http://www.forexchartingsoftware.info/pc.gif[/img]
Re: Python Exercise by 8ightball: 7:20pm On Oct 13, 2012
ask away
Re: Python Exercise by ufumes(m): 5:22pm On Oct 27, 2012
Retrieve the ist character of the word assign it to a variable. Retrieve the last character and assign it to a variable. Then concatenate the last variable + the word (excluding the ist and last) + the first character

(1) (Reply)

How Much Will You Charge A Microfinance Bank In A Town For Banking Application / A Student Developed A Chip To Charge Mobile Phones When Placed In Shoe Soles / Hospital Management Solution - A JAVA Program

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.