Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 4d42cde1e6dc010cb7000024

expand a list comprehension (python)

Please show your way to convert a list comprehension in python to an ordinary for-loop expression!

Start file
print [x**2 for x in xrange(10)]
End file
tmp = []
for x in xrange(10):
    tmp.append(x**2)
print tmp

View Diff

1c1,4
< print [x**2 for x in xrange(10)]
---
> tmp = []
> for x in xrange(10):
>     tmp.append(x**2)
> print tmp

Solutions

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 75 remaining solutions by signing in and submitting your own entry
#76 Steven Occhipinti / steveocchipinti - Score: 65 - 02/03/11 @ 03:27
"adwl"bdt x"cdt]Itmp = <Esc>o<C-R>c:<CR>tmp.append(<C-R>b)<CR><C-D><C-R>atmp<Esc>:%s;\t;    <CR>ZZ

0 comments

#77 Dj Vimgolf / dj_vimgolf - Score: 65 - 12/31/11 @ 01:16
c8wtmp = []<CR>for x in <End><BS>:<CR><BS>    tmp.append(x**2)<CR><BS><BS><BS><BS>print tmp<Esc>:wq<CR>

0 comments

#78 Matthieu Honel / ocus - Score: 66 - 01/28/11 @ 15:31
itmp = []<CR><Esc>vf "axxvf "bx$r:otmp.append(<Esc>"bpi)<CR><Esc>"apAtmp<Esc>k<<i    <Esc>ZZ

0 comments

#79 Helder Inacio / inaciohj - Score: 67 - 02/03/11 @ 03:32
dwo<Esc>pkxdt]<Esc>o<Esc>pA:<Esc>khdi[jo<C-U><Esc>4a <Esc>atmp.apped<C-H>nd()<Esc>Pjatmp<Esc>ggItmp = <Esc>:wq<CR>

0 comments

#80 Torben Rasmussen / rasmustorben - Score: 67 - 08/16/11 @ 16:34
witmp<NL><Esc>..lv$hhdkJa= <Esc>kp0fxi.append(<Esc>Ea)<Del><NL><Esc>A:<Esc>k4I <Esc>ddpggddGpkddggPZZ

0 comments

#81 Dmitry Teslenko / krab_mozga - Score: 69 - 02/02/11 @ 09:43
witmp<Esc>yiwwpa.append(<Esc>/2<CR>a)<Esc>?[<CR>i<Esc>pa = <Esc>?t<CR>d$O<Esc>pdn<Esc>o<Esc>pa:<Esc>?f<CR>d^o<Esc>px^4PZZ

0 comments

#82 Patrice Clement / patrice_clement - Score: 69 - 03/18/14 @ 20:32
Otmp = []<NL><Esc>/f<NL>df)kPA:<Esc>jyyP>>ui    tmp.<Esc>lceappend<Esc>lxr(ElC)<Esc>jBCtmp<Esc>:wq<NL>

0 comments

#83 Jon Bettinger / jonbettinger - Score: 70 - 01/31/11 @ 02:35
ffi<CR><Esc>3XXx$r:<CR>o    tmp.append(x**2)<CR>print tmp<Esc>^XXXX:q<BS>1<CR>Ditmp = []<Esc>:wq<CR>

0 comments

#84 stefan otte / stefanotte - Score: 70 - 01/30/12 @ 13:39
itmp <Esc>ww.i<CR><Esc>veE<Right>xpuo<Esc>p<Up>A<BS>:<Esc><Down>I    tmp.append(<Del><Esc>A<BS>u<BS>)<Esc>ggwi= []<CR><Esc>dd<Down>p:wq<CR>

0 comments

#85 Arto Vuori / dhpe - Score: 70 - 09/01/12 @ 16:50
Itmp = []<CR><Esc>kywjfxPi.append(<Del><Esc>f r)o<Esc>p<Esc>xkdiwjPa <Esc>kffdf)O<Esc>pa:<Esc>jxF[x3i <Esc>ZZ

0 comments

#86 Vernon Thommeret / synotic - Score: 72 - 01/30/11 @ 15:38
ffdf)o<Esc>pkFx4xjo    tmp.append(<Esc>pa)<CR>p<BS><BS><BS><BS><BS>print tmp<Esc>ggciwtmp =<Esc>3lxj$a:<Esc>ZZ

0 comments

#87 Christopher Brew / Seph1rothVII - Score: 72 - 01/11/12 @ 00:41
dWo<Esc>pi<Right>tmp<Esc>bywggP<Right>i<CR>    <Esc><Right>puui<CR>    <Esc>pi<Right>.append<Esc><Right>r(W<Left>r)<Right>d$<Up>i<Right> = []<CR><Esc>pr:ZZ

0 comments

#88 Pavlo Klets / p01nt - Score: 73 - 01/28/11 @ 15:27
dwo<Esc>patmp<Esc><Left><Left>ywO<Esc>4i <Esc>pa.appent<BS>d()<Esc><Up>$x^p<Left>2xO<Esc>p^itmp = <Esc><Down>^3dw:<Esc>^$a:<Esc><Down>Px:wq<CR>

0 comments

#89 Franco Lazzarino / flazz - Score: 75 - 01/29/11 @ 00:51
ea tmp =<Esc>bywPi<CR><Esc>kddp<Esc>Otmp.append()<Esc>kdi]<Esc>o<Esc>pa:<Esc>0d/for<CR>/(n<BS><CR>P<Esc>ujP<Esc>I    <Esc>f xZZ

0 comments

#90 grizzancs / grizzancs - Score: 75 - 01/31/11 @ 12:13
Ctmp = []<CR>for x in xrange(10):<CR>tmp.append(x**2)<Esc><<i    <Esc>o<BS><BS><BS><BS>print tmp<Esc>:wq<CR>

0 comments

#91 Solomon White / rubysolo - Score: 79 - 01/28/11 @ 16:58
/f<CR>hs<CR><Esc>$s:<Esc>kddp<Esc>els<CR><Esc>kddp<Esc>ks    tmp.append(<Esc>A)<Esc>ja tmep<BS><BS>p<Esc>ggOtmp = []<Esc>jnd0<Esc>:wq<CR>

0 comments

#92 Reza Lotun / rlotun - Score: 104 - 01/30/11 @ 18:32
wwwwwv$hhlda<CR><BS><BS><Esc>pxkVdpxxxxxxxi    tmp.append(<Esc>$a<BS>)<Esc>ka:<Esc>ja<Esc>0Gggi<CR><Esc>ktmp<Esc>x<Esc>itmp = []<Esc>G$a<CR><BS><BS><BS><BS>print tmp<Esc>:wq<CR>

0 comments

#93 Ilya Grigorik / igrigorik - Score: 141 - 02/01/11 @ 00:43
i<CR><Up>tmp = []<Down><Esc>ddi<Esc>ofor x in xrange(10):<CR>    tmp.append(x**2)<CR>print tmp<Esc>u:set paste<CR>i<Esc>ofor x in xrange(10):<CR>    tmp.append(x**2)<CR>print tmp<Esc>:wq<CR>

0 comments

#94 David Burns / AutomatedTester - Score: 146 - 01/28/11 @ 15:17
itmp = []<CR><Esc><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>v<Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>x<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>pu<Left>o<Up><CR><Up><Esc>pi<Right>:<Down><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><CR><Up><Tab><BS>    tmp.append(<Esc><Down><Right>v<Right><Right><Right>x<Up>pi<Right>)<Down><BS><BS><BS>tmp<Esc><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>dw<Down>dd:wq<CR>

0 comments

Created by: vimgolfer

94 active golfers, 237 entries

Leaderboard (lowest score wins):
42
#1 - xhtmlforum / xhtmlforum

01/28/2011 at 10:51PM

42
#2 - Pete Johns / johnsyweb

01/29/2011 at 12:48AM

42
#3 - Tim Chase / gumnos

01/29/2011 at 12:56AM

42
#4 - Stephen Morrow / yawmark

01/29/2011 at 02:48PM

42
#5 - Wei Dai / clvv42

01/30/2011 at 03:58AM

42
#6 - Oleg Roshupkin / jjjahson

02/01/2011 at 11:39AM

42
#7 - Ujjwol Lamichhane / Ujjwol

02/03/2011 at 02:58AM

42
#8 - Balkoth / _Balkoth_

02/03/2011 at 09:45PM

42
#9 - Hu Junfeng / junfeng

08/01/2011 at 02:42PM

42
#10 - You-Siang Lin / yslinnctu

11/30/2011 at 05:39AM

42
#11 - Urtica dioica / udioica

12/16/2012 at 04:24AM

42
#12 - Marco Hinz / _mhinz_

05/28/2013 at 08:19AM

42
#13 - John Braxler / braxler

06/09/2014 at 10:16PM

43
#14 - Federico Galassi / federicogalassi

01/28/2011 at 09:52PM

43
#15 - flo / c4p0ne

01/31/2011 at 01:06PM

43
#16 - Justin Love / wondible

09/07/2011 at 12:54PM

43
#17 - Rändöm Tester / mevcar

02/12/2012 at 03:59PM

43
#18 - William Dunand / wdunand

03/06/2012 at 08:34AM

44
#19 - Michał Taszycki / mehowte

01/29/2011 at 06:51PM

44
#20 - Joonas Pihlajamaa / jokkebk

02/25/2014 at 03:25PM

45
#21 - Jon Krause / jkrause314

04/18/2016 at 10:39PM

46
#22 - h_east (トロッコ6個) / h_east

01/29/2011 at 07:26AM

47
#23 - Zak Johnson / zakj

04/21/2011 at 01:41AM

47
#24 - Øystein Walle / oysteinwalle

07/08/2011 at 08:15PM

47
#25 - Renat Aksitov / Korvin79

02/26/2012 at 06:30PM

47
#26 - Kerson Hsiao / KersonHsiao

08/03/2012 at 03:45AM

48
#27 - timhoa / timhoa

01/29/2011 at 09:14PM

48
#28 - Ivan Nečas / iNecas

01/31/2011 at 10:56PM

48
#29 - Christopher Erin / MCNormalMode

09/27/2011 at 12:36AM

49
#30 - Xavier Nayrac / lkdjiin

01/08/2012 at 11:35AM

49
#31 - cj / cj01101

02/05/2014 at 10:55PM

50
#32 - Eivind Jahren / HaskellElephant

02/02/2011 at 10:14PM

50
#33 - Ibrahim Tencer / ibrahimtencer

02/13/2012 at 04:40AM

50
#34 - Yann Moisan / YannMoisan

01/13/2013 at 07:57PM

51
#35 - Dan Masquelier / danmasq

07/01/2011 at 09:32PM

51
#36 - Jesús Espino / jespinog

09/06/2011 at 10:29PM

51
#37 - 無ん垢の叫び / john_ababa

02/27/2012 at 08:04AM

51
#38 - Daniel Lundin / danielundin

05/11/2012 at 12:20PM

51
#39 - John Piasetzki / jpiasetz

07/13/2012 at 07:03AM

52
#40 - iCross / iCrossOfficial

01/30/2011 at 07:46PM

52
#41 - Thom Hughes / thom_hughes_1

03/27/2011 at 01:42PM

52
#42 - Nolen Royalty / NolenRoyalty

04/20/2012 at 06:25PM

52
#43 - r. / rmarvie

12/23/2014 at 09:05PM

53
#44 - Premium Ben / muppling

02/07/2011 at 08:22PM

53
#45 - Arthur Hinh / arthur_hinh

03/26/2011 at 04:20AM

53
#46 - Avinash Baliga / avinashbaliga

03/27/2011 at 08:41PM

54
#47 - Artem Dudarev / dudarev

01/30/2011 at 04:25PM

54
#48 - Joost / vlabakje

02/12/2011 at 12:29AM

54
#49 - Nicola Paolucci / durdn

02/25/2011 at 09:04PM

54
#50 - Mauro Persano / fzort

11/22/2014 at 03:50PM

55
#51 - Jay Phillips / jicksta

01/30/2011 at 09:15PM

55
#52 - Chris Penkett / chrispenkett

04/03/2012 at 06:57PM

55
#53 - James / Dronak

09/20/2014 at 05:54PM

56
#54 - Matti Hänninen / mjhanninen

01/30/2011 at 09:35PM

56
#55 - Ian McCowan / valrus

05/29/2011 at 08:34PM

56
#56 - Dave / zzdave13

07/18/2011 at 09:29PM

56
#57 - Ayose Cazorla / ayosec

09/03/2011 at 04:03PM

57
#58 - Amy / imightbeAmy

02/15/2013 at 05:47PM

57
#59 - Richard Davison / richarddavison

07/14/2017 at 05:28PM

58
#60 - James Cash / jamesnvc

01/28/2011 at 03:45PM

58
#61 - Alekseyka2 / Alekseyka2

01/28/2011 at 10:30PM

58
#62 - Mark Smith-Guerrero / msmithgu

02/01/2011 at 06:06PM

58
#63 - Alex Hammel / AlexJHammel

12/23/2012 at 03:05PM

59
#64 - Rob Ciaccio / RobertoCalavera

01/28/2011 at 06:16PM

59
#65 - Daniel / dpaneda

09/26/2011 at 10:47PM

59
#66 - banana / sparkleseed

03/13/2012 at 03:37PM

59
#67 - Munzor / t3hmun

04/28/2014 at 06:38PM

60
#68 - Michael Perrone / ThePerrone

12/22/2013 at 03:28AM

60
#69 - Daniel Jonsson / DanielJonss

01/21/2014 at 04:47PM

60
#70 - かしゅーなっつ@修行中 / kashew_nuts

08/02/2014 at 08:38AM

62
#71 - Rörd Hinrichsen / roerdhh

01/29/2011 at 03:03AM

62
#72 - Nomen Nescio / vadtusan

04/14/2011 at 08:03AM

63
#73 - Federico Bond / federicobond

09/22/2012 at 11:15PM

63
#74 - Gurukandhamoorthi / Gurukandhamoor1

09/02/2017 at 05:03PM

64
#75 - Burkhard Zimmermann / BurkZimm

12/26/2011 at 11:35PM

65
#76 - Steven Occhipinti / steveocchipinti

02/03/2011 at 03:27AM

65
#77 - Dj Vimgolf / dj_vimgolf

12/31/2011 at 01:16AM

66
#78 - Matthieu Honel / ocus

01/28/2011 at 03:31PM

67
#79 - Helder Inacio / inaciohj

02/03/2011 at 03:32AM

67
#80 - Torben Rasmussen / rasmustorben

08/16/2011 at 04:34PM

69
#81 - Dmitry Teslenko / krab_mozga

02/02/2011 at 09:43AM

69
#82 - Patrice Clement / patrice_clement

03/18/2014 at 08:32PM

70
#83 - Jon Bettinger / jonbettinger

01/31/2011 at 02:35AM

70
#84 - stefan otte / stefanotte

01/30/2012 at 01:39PM

70
#85 - Arto Vuori / dhpe

09/01/2012 at 04:50PM

72
#86 - Vernon Thommeret / synotic

01/30/2011 at 03:38PM

72
#87 - Christopher Brew / Seph1rothVII

01/11/2012 at 12:41AM

73
#88 - Pavlo Klets / p01nt

01/28/2011 at 03:27PM

75
#89 - Franco Lazzarino / flazz

01/29/2011 at 12:51AM

75
#90 - grizzancs / grizzancs

01/31/2011 at 12:13PM

79
#91 - Solomon White / rubysolo

01/28/2011 at 04:58PM

104
#92 - Reza Lotun / rlotun

01/30/2011 at 06:32PM

141
#93 - Ilya Grigorik / igrigorik

02/01/2011 at 12:43AM

146
#94 - David Burns / AutomatedTester

01/28/2011 at 03:17PM