here is the problem I am having. I have a list of strings: ["a","b","b","b","b","b","c","c","c","c","c","d","d","d","d","d"]
I want to label each element in the list in which they appear, so input file as argument
#!/usr/bin/python
import sys
filename=sys.argv[1]
with open(filename) as f:
#what the text file should look like:
a
b
b
b
b
b
c
c
c
c
c
d
d
d
d
d
#what I want the output to look like:
1 a
2 b
3 c
4 d
5 b
6 b
7 b
8 b
9 c
10 c
11 c
12 c
13 d
14 d
15 d
16 d
through the text file start with the first occurrence of each letter then once those are labeled continue and label the rest in order
not sure what the best way to go about it is
here is the problem I am having. I have a list of strings: ["a","b","b","b","b","b","c","c","c","c","c","d","d","d","d",
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am