numbered

Numbered list in python

倖福魔咒の 提交于 2020-01-30 08:05:28
问题 I need to make a numbered list from list elements in python. Example list: destinations = ['Los Angeles ', 'Rhodos ', 'Dubai ', 'Manila ', 'Mallorca ', 'New York '] I need to print out elements as numbered list: 1. Los Angeles 2. Rhodos 3. Dubai 4. Manila 5. Mallorca 6. New York If I do: print ('\n'.join(destinations)) It prints out elements on separate lines, but I cannot add numbers. 回答1: You simply use enumerate() and count from 1 >>> destinations = ['Los Angeles ', 'Rhodos ', 'Dubai ',

How do I make ordered list using javascript?

こ雲淡風輕ζ 提交于 2019-12-12 02:39:20
问题 Lets say I have this <ol> <li>V1 One</li> <li>V1 Two</li> <li>V1 Three</li> <li>V1 Four</li> </ol>` I want to make an ordered list using .js instead of using LI tags. I was thinking the js. code could replace first V1 and call it 1. , replace second V1 and call it two and so on, in other words counting how many V1s there are and replacing them with ordered list. Or maybe something like this <ol> <li>i++ V1 One</li> <li>i++ V1 Two</li> <li>i++ V1 Three</li> <li>i++ V1 Four</li> </ol> Where i++