6130093021 -> 0.74 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt","r") for line in f : ln = line.strip().split(' ') ddd = [] for x in ln : if x !='': if ('1' <= x[0] <= '9'): if len(x) > 3 : g = [] if len(x)%3 ==1: p = x[0] g.append(p) for i in range(1,len(x)-2,3): g.append(x[i:i+3:]) elif len(x)%3 ==2: p = x[:2:] g.append(p) for i in range(2,len(x)-2,3): g.append(x[i:i+3:]) elif len(x)%3 ==0: for i in range(0,len(x)-2,3): g.append(x[i:i+3:]) uu = ','.join(g) ddd.append(uu) else: ddd.append(x) else: ddd.append(x) print(" ".join(ddd)) f.close |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6130270821 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6230058821 -> 0.0 -> invalid syntax (<string>, line 70) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt","r") n = 9 for line in infile : for i in range (n): line = if 1<= f(i) <=9 : infile.close() |
6230584521 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") d = [] for line in fn: l = line.strip().split() for i in range(len(l)): if l[i].isnumeric() == True and l[i][0] !="0": s = "" ; j = 0 for k in l[i][::-1]: j+=1 if j%3!=0: s+=k else: s+=k+"," s = s[::-1] l[i] = s d.append(l) for i in range(len(d)): for j in range(len(d[i])): if d[i][j][0] == ",": d[i][j] = d[i][j][1::] print(" ".join(d[i])) fn.close() #ขออนุญาตเขียนเพิ่มเติมครับ ถามอาจารย์สมชายแล้ว อาจารย์บอกว่า "ส่งก็ส่งเฉพาะโปรแกรมที่ให้เขียน ตอนตรวจ ผู้ตรวจะสร้างแฟ้มนั้นเองครับ" #ผมทำตามคำสั่งแล้วครับว่า ส่งแต่โค้ด ผมเลยไม่ได้อัพไฟล์ data.txt ไว้ครับ ขอบคุณครับ |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6231501621 -> 0.0 -> expected an indented block (<string>, line 86) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt","r") for line in infile: |
6231718521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6330242021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. data = input().split(' ') f = []; g='' infile = open("data.txt","r") for line in infile: for e in data: if len(e) > 3: if '1' <= e[0] <= '9': k = len(e)%4 e = (e[0:k+1]+','+e[k+1::]) f.append(e) g += ' '.join(str(e) for e in f) infile.close() print(g) |
data.txtdata.txt data.txtdata.txt data.txt data.txtdata.txt data.txt data.txt data.txtdata.txt data.txt data.txt data.txt data.txt |
6330594921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. ff = [] f = open("data.txt") for line in f: b = [] line = line.split() for i in line: a = [] if i.isnumeric(): run = 0 for j in i[::-1]: run += 1 a.append(j) if run == 3: run = 0 a.append(",") b.append("".join(a[::-1]).strip()) else: b.append(i) ff.append(b) f.close() |
6331507521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430002821 -> 0.0 -> string indices must be integers |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn=open('data.txt') a='' y='' for line in fn: l=line.split() for k in l: if '0'<=k<='10000000000000000000000000': k=k[::-1] for i in range(0,len(k),3): y+=k[i:i+3,1]+',' y=y[::-1] a+=y else : a+=k print(a) fn.close() |
6430004021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt","r") for line in infile: print(line) infile.close() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6430006321 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt", "r" ) x = fin.read() print(x) fin.close() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6430009221 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def my_value(number): return ("{:,}".format(number)) fn = open('data.txt','r') for line in fn: line = line.strip() x = line.split() for i in range(len(x)): if x[i].isnumeric(): if x[i][0] != '0': x[i] = my_value(int(x[i])) print(' '.join(x)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430014321 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt') data = fin.readlines() for line in data: line = line.strip('\n').split(' ') for i in range(len(line)): if line[i].isnumeric() and not line[i].startswith('0'): line[i] = "{:,}".format(int(line[i])) print(' '.join(line)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430019521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt','r') num = [] for line in fin: for ch in line.split(' '): if ch == '': num.append('*') else: num.append(ch) for e in num: if e.isdigit() or e[:-2:].isdigit(): if e[0] != '0': if len(e) > 3: if 4 <= len(e) <= 6: re = e[::-1] re1 = re[:3] + ',' + re[3:] re2 = re1[::-1] num[num.index(e)] = re2 elif not(e[-2:].isdigit()): e1 = e[:-1] re = e1[::-1] re1 = re[:3] + ',' + re[3:] re2 = re1[::-1] num[num.index(e)] = re2 + '\n' print(''.join(num)) fin.close() |
99523000***plus***989,000equals****100512,000 1121231,23412,345123,456 Mynumberis0894435618123456712345678123456,789 1234567890123456789plus1234567890123456789012345A234123422,12a 1234567890123456789012is123456789012345678901 |
6430023021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430024621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') f1 = f.readline() f2 = f.readline() lst1 = f1.strip().split() for i in range(0,5,2): if 1000 <= int(lst1[i]) < 10000: lst1[i] = lst1[i][0] + ',' + lst1[i][1:] elif 10000 <= int(lst1[i]) < 100000: lst1[i] = lst1[i][:2] + ',' + lst1[i][2:] elif 100000 <= int(lst1[i]) < 1000000: lst1[i] = lst1[i][:3] + ',' + lst1[i][3:] elif 1000000 <= int(lst1[i]) < 10000000: lst1[i] = lst1[i][0] + ',' + lst1[i][1:4] + ',' + lst1[i][4:] f.close() x = ' '.join(lst1[:4]) print(x+' '+lst1[4]) print(f2) |
99523000 plus 989,000 equals 100512000 1 12 123 1234 12345 123456 |
6430030321 -> 0.0 -> 'str' object has no attribute 'append' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt','r') line = fin.readline() for line in fin: out = '' for e in line.split(): if '0'<e[0]<='9': c=0 block = '' for k in e[::-1]: if c==3: c=0 block = k +','+ block else: block = k + block c+=1 out.append(block) else: out.append(e) print(' '.join(out)) fin.close() |
6430031021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f1 = open('data.txt') for line in f1: x = line.split() num = [] fixnum = [] ans = '' for e in x: if e.isnumeric() and e[0] != '0': num.append(e) for e in num: u = list(e) for i in range(len(u))[::-3][1:]: u.insert(i+1,",") result = "".join(u) fixnum.append(result) c = 0 for e in fixnum: ind = line.find(e) ans = ans[:ind] if c == 0: ans += e+line[len(e)-1:] else: ans += line[ind:len(e)+1]+e c += 1 print(ans) f1.close() |
99,523,000 plus 989000 equals 100512000989,00100,512,000 11112121,2312,34123,456 1,234,567r is 0894435618 1234567 12345678 12345678912,345,67123,456,789 1,234,567,890,123,456,789 12345678901234567890 12345A234 12342212a12,345,678,901,234,567,890 1,234,567,890,123,456,789,012345678901234567890123,456,789,012,345,678,901 |
6430032621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. d=open('data.txt','r') for i in d: line='' i=i.strip() i+=',' for j in range(len(i)-1,-1,-1): c=False if '0'<=i[j]<='9': for l in range(j-1,-1,-1): if i[l] not in [str(e) for e in list(range(10))]: if abs(l-j)>=3: for k in range(j-1,-1,-1): if '1'<=i[k]<='9' and abs(k-j)==2: line+=i[j:k]+',' k=k c=True break else: line+=i[j] k=j c=True break if c==True: break else: line+=i[j] k=j print(line[:0:-1]) d.close() |
plus 989000 equals 100512000 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 plus 12345678901234567890 12345A234 12342212a is 123456789012345678901 |
6430033221 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open( "data.txt") numcnt = 0 cnt = 0 numnow = False ignore = False for i in f.read().splitlines(): s = i.split() spaces = [] spacecnt = 0 for j in i : if j == ' ' : spacecnt += 1 if spacecnt != 0 and j!= ' ' : spaces.append(spacecnt) spacecnt = 0 l = '' if s[0].isnumeric() : if s[0][0] == '0' : l += s[0] else : l += "{:,}".format(int(s[0])) else : l += s[0] for i in range (len(spaces)) : l += ' '*spaces[i] if s[i+1].isnumeric() : if s[i+1][0] == '0' : l += s[i+1] else : l += "{:,}".format(int(s[i+1])) else : l += s[i+1] print(l) #print(spaces) #print(s) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430038421 -> 0.74 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fname=input().strip() fin=open(fname,'r') Add=True for line in fin: x=line.split() l=[] for i in x: k = '' if '1'<=i[0]<='9': if len(i)>3: k+=i[:len(i)%3] i=i[len(i)%3:] for j in range(len(i)): if j%3==0 and k!='': k+=','+i[j] else: k+=i[j] else: k=i else: k=i l.append(k) k='' out=' '.join(l) print(out) fin.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430044121 -> 0.0 -> expected an indented block (<string>, line 85) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. n = input().strip().split() file = open(n[0],'r') for line in file : |
6430047021 -> 0.71 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt") for line in infile: x = line.split() ch = [] for i in x: if i[0] in "2134567890": e = str(i)[::-1] s = "" for n in range(0,len(e),3): s += e[n:n+3] + "," ch.append(s[:-1][::-1]) else: ch.append(i) print(" ".join(ch)) infile.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0,894,435,618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430050921 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fopen = open('data.txt', 'r') def add_commas(instr): out = [instr[0]] for i in range(1, len(instr)): if (len(instr) - i) % 3 == 0: out.append(',') out.append(instr[i]) return ''.join(out) for line in fopen : haha = '' x = line.strip().split() for i in x : if i.isnumeric() == True and i[0] != '0' and len(i) > 3 and len(haha) == 0 : haha += add_commas(i) elif i.isnumeric() == True and i[0] != '0' and len(i) > 3 : haha += ' ' + add_commas(i) elif len(haha) == 0 : haha += i else : haha += ' ' + i print(haha) fopen.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430051521 -> 0.0 -> string index out of range |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt",'r') wow = [] for line in fn: use = line.split() for e in use: if e[0] in '123456789': new = e[::-1] new_use = '' for i in range(1,len(e)+1): if i == 1: new_use += new[i] elif i%3 == 0 and i != len(e): new_use += new[i] + ',' else: new_use += new[i] x = new_use[::-1] wow.append(x) else: wow.append(e) print(' '.join(use)) |
6430053821 -> 0.25 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. file1 = open("data.txt","r") x = [] for line in file1: x.append(line.split("\n")) for i in range(len(x)): x[i] = x[i][0] file1.close() ref = [] for item in x: ref.append(item.split()) for i in range(len(ref)): for e in range(len(ref[i])): check = True for char in ref[i][e]: if char not in "0123456789": check = False break if (len(ref[i][e]) > 3) and ref[i][e][0] != "0"\ and check: ref[i][e] = ref[i][e][0:-3] + "," + ref[i][e][-3:] for item in ref: print(" ".join(item)) |
99523,000 plus 989,000 equals 100512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1234,567 12345,678 123456,789 1234567890123456,789 plus 12345678901234567,890 12345A234 12342212a 1234567890123456789,012 is 123456789012345678,901 |
6430056721 -> 0.71 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt', 'r') for line in fin: line = line.strip() x = '' num = [] c = 0 for i in range(len(line)-1,-1,-1): if 'A' <= line[i] <= 'z' or line[i] == ' ': c = 0 x += line[i] elif '0' <= line[i] <= '9': c += 1 x += line[i] if (c == 3 and x[-3] != 0) and line[i-1] != ' ': x += ',' c = 0 print(x[::-1]) fin.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0,894,435,618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12,345A,234 12,342,212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430057321 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430061821 -> 0.4 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt","r") for e in fin : text = "" for k in e.split() : bla = 0 for j in k : if j == " " : bla += 1 num = ' '*bla use = k.strip() if '1'<= use[0]<='9' : if len(use) > 3 : c = 1 for i in use : if c%3 == len(use)%3: num += i+',' else : num += i c+=1 num = num[:-1] else : num = k text += ' '+num print(text.strip()) |
99,523,000 plus 989,000 equals 100,512,000 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430066021 -> 0.25 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. inp = open('data.txt','r') #print((inp.read())) for line in inp: wl = [] word = '' num = '1234567890' for i in line: if word == '': word=i else: if i in num and word[0] not in num: wl.append(word) word = i elif i not in num and word[0] in num: wl.append(word) word = i else: word+=i if word == line[len(line)-len(word):]: wl.append(word) for w in range(len(wl)): if wl[w][0] in num and wl[w][0] != '0': if len(wl[w])>=4: reverse = wl[w][::-1] count = 0 added = '' for r in reverse: if count == 3: added=(added+','+r) count = 0 else: added+=r count+=1 wl[w] = added[::-1] if wl[-1] == '\n': wl.remove('\n') elif '\n' in wl[-1]: wl[-1] = wl[-1][:-1] tw = ''.join(wl) print(tw) inp.close() |
9,9523,000 plus 989,000 equals 10,0512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1234,567 1,2345,678 12,3456,789 1234,5678,9012,3456,789 plus 1,2345,6789,0123,4567,890 12,345A234 1,2342,212a 11234,5678,90112,3456,7890,1234,5678,901123,4567,8901,2345,6789,012 is 11234,5678,90112,3456,7890,1234,5678,901 |
6430072721 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430075621 -> 0.0 -> invalid syntax (<string>, line 79) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt","r") line = fin.readline() for line in fin: x=line.split(' ') out = '' for i in range(len(x)): what = x[i].strip() if what == int and what[0]!=0: if len(what)>=4 and len(what)<7: what = (str(what[-1:-4])+','+str(what[-4:]))[::-1] out += what+' ' elif len(what)>=7 and len(what)<10: what = (str(what[-1:-4])+','+str(what[-4,-7])+','+str(what[-7:]))[::-1] out += what += ' ' else: out+=x[i]+' ' print(out[:-1]) fin.close() |
6430077921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430078521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430080721 -> 0.0 -> invalid syntax (<string>, line 69) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. data = open("data,txt") for line in data: l = line[::-1] if |
6430083621 -> 0.49 -> invalid literal for int() with base 10: '12345A234' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. file = open("data.txt", "r") for line in file: a = [] x0 = line.rstrip("\n") x = x0.split() for i in x: if "1" <= i <= "9": b = int(i) c = f'{b:,}' a.append(str(c)) else: a.append(i) a1 = " ".join(a) print(a1) file.close() |
99523000 plus 989000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 |
6430091621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt" , "r") k =True for i in fn: x = i.split() for e in x: if e[0] != "0": for j in e: if j in "0123456789": k = True else: k = False break if k == True: if len(e)>3: e = e[0:-3] + "," + e[-3::] print(" ".join(x)) fn.close() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6430095121 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn=open('data.txt','r') x=fn.read().split('\n') fn.close() out=[] for y in x: a=y.split(' ') b=[] for i in range(len(a)): if a[i].isnumeric()==True and a[i][0]!='0': k='' for j in range(1,len(a[i])+1,1): if j%3==1 and j!=1: k+=',' k+=a[i][-j] b.append(k[::-1]) else: b.append(a[i]) out.append(' '.join(b)) print('\n'.join(out)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430097421 -> 0.0 -> expected an indented block (<string>, line 70) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. infile = open(data.txt,'w') for line in infile: for w in line.split().strip(): if 1<=int(w[0])<=9: infile.close() |
6430098021 -> 0.2 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. A = open("data.txt" , "r") L1 = A.readline().strip() L2 = A.readline().strip() A.close() def addcom(x): str = "" x = x[::-1] for i in range(len(x)): if (i) % 3 == 0 and i != 0: str += "," str += x[i] return str[::-1] LL1 = [] l1 = L1.split(" ") for i in l1: if len(i) == 0: LL1.append("") elif "0" <= i[0] <= "9": adc = addcom(i) LL1.append(adc) else: LL1.append(i) STR = " ".join(LL1) + "\n" + L2 print(STR) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1234 12345 123456 |
6430104121 -> 0.6 -> invalid literal for int() with base 10: '12345A234' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt','r') for line in fin: temp = line.split(' ') for i in range(len(temp)) : if temp[i] != '' : if temp[i][0].isnumeric() : #"{:,}".format(1000) if temp[i][0] != '0': temp[i] = "{:,}".format(int(temp[i])) print(" ".join(temp)) fin.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 |
6430106421 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fread = open('data.txt' , 'r') for i in fread : count = 0 line = "" for e in i : if '1' <= e <= '9' : count += 1 line += e if count%3 == 0 : line += ',' elif e == '0' : count = 0 line += e else : line += e print (line) |
995,23000 plus 9,89000 equals 1,00512,000 1 12, 123, 123,4 12,345, 123,456, My number is 0894,435,618, 123,456,7 12,345,678, 123,456,789, 123,456,789,0123,456,789, plus 123,456,789,0123,456,789,0 123,45A2,34 1,234,221,2a 123,456,789,0123,456,789,012 is 1,234,567,8901,234,567,8901, |
6430108721 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430111521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430115021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430116721 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430117321 -> 0.71 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt" ,'r') x='' for line in fn: lst=[] for i in range(len(line)): if line[i] in ['1','2','3','4','5','6','7','8','9','0']: lst+=[line[i]] if i!= len(line)-1: if len(lst)!=0 and line[i+1] not in ['1','2','3','4','5','6','7','8','9','0'] : if lst[0]=='0'or len(lst)<4: x+=''.join(lst) else: y='' for j in range(-1,-1*(len(lst)+1),-1): if j%3==2: y+=','+lst[j] else: y+=lst[j] x+=y[::-1][:-1:] lst=[] else: if lst[0]=='0'or len(lst)<4: x+=''.join(lst) else: x+=line[i] print(x) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12,345A234 12,342,212a 1,234,567,890,123,456,789,012 is |
6430124721 -> 0.25 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def read_file(filename): fo = open(filename) file = fo.read().strip() fo.close() '''file = file.split('\n')''' return file a = read_file('data.txt') b = a.split() #print(b) ans = '' ansl = [] for e in b: stri = '' c = 0 #print(e.isnumeric()) if e.isnumeric() and e[0] != '0' and len(e)>3: for f in e: c+=1 if c == len(e)-2: stri += ',' stri += f ans += stri else: ans += e ans += ' ' print(ans) |
99523,000 plus 989,000 equals 100512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1234,567 12345,678 123456,789 1234567890123456,789 plus 12345678901234567,890 12345A234 12342212a 1234567890123456789,012 is 123456789012345678,901 |
6430125321 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def ts(n): x = str(n)[::-1] s = "" for i in range(0, len(x), 3): s += x[i:i+3] + "," return s[:-1][::-1] fn = open('data.txt','r') fo = open('result.txt','w') for t in fn: x = t[:-1] r = '' for e in x: if e == ' ': e = '_' r +=e else: r+=e a = r.split('_') w = [] for e in a: if len(e) > 3: if e[0] != '0' and '0' <= e[1] <= '9': w.append(ts(e)) else: w.append(e) else: w.append(e) fo.write(' '.join([e for e in w])) fo.write('\n') fn.close() fo.close() |
6430129921 -> 0.25 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. s = input().strip() file = open(s) data = [] for i in file.readlines(): p = i.split() p[-1] += '\n' data.extend(p) for k in range(len(data)): ori = data[k] if data[k].strip().isalnum() == True: t = '' for j in data[k]: if j.isnumeric() == True: t += str(j) tor = t if len(t) > 3 and t[0] != '0': for a in range(-3,-len(t),-3): t = t[0:a] + ',' + t[a::] data[k] = data[k][0:data[k].find(tor)] + str(t) + data[k][(data[k].find(tor))+len(t)::] if ori[-1:-3] == 'n\\' : data[k] += '\n' print(' '.join(data)) |
995,23,000 plus 989,000 equals 1005,12,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 12,34,567 123,45,678 1234,56,789 123456,78,90,12,34,56,789 plus 1234567,89,01,23,45,67,890 12345A23123,45,234 123,42,212 1234567,89,01,23,45,67,89,012 is 12345678,90,12,34,56,78,901 |
6430133321 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def nu(x): x=x[::-1] c=0 s='' for i in range(len(x)): if(c==3): s+=',' c=0 s+=x[i] c+=1 return s[::-1] f = open('data.txt') li=[] for line in f: li.append(line.split()) a=line print(li) li[0][4]=int(li[0][0])+int(li[0][2]) li[0][4]=str(li[0][4]) print(nu(li[0][0])+' '+li[0][1]+' '+nu(li[0][2])+' '+li[0][3]+' '+nu(li[0][4])) print(a) f.close() |
[['99523000', 'plus', '989000', 'equals', '100512000'], ['1', '12', '123', '1234', '12345', '123456'], ['My', 'number', 'is', '0894435618', '1234567', '12345678', '123456789'], ['1234567890123456789', 'plus', '12345678901234567890', '12345A234', '12342212a'], ['1234567890123456789012', 'is', '123456789012345678901']] 99,523,000 plus 989,000 equals 100,512,000 1234567890123456789012 is 123456789012345678901 |
6430136221 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430150021 -> 0.0 -> list indices must be integers or slices, not tuple |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. a="" f = open('data.txt') for line in f: a+=str(line) f.close() a=a.split() for i in range(len(a)): if int(a[i][0]) in [1,2,3,4,5,6,7,8,9]: if int(a[i])>=1000: k=len(a[i]) a[i]=a[0,k-3]+","+a[-3:0] m=" ".join(a) print(m) |
6430158021 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", "r") for line in f.read().split("\n"): new = [] for i in line.split(" "): if (i.isnumeric() and i[0] != "0"): new.append("{:,}".format(int(i))) else: new.append(i) print(" ".join(new)) f.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6430159721 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430160221 -> 0.0 -> invalid literal for int() with base 10: '12345A234' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt") l = [] r = [] for i in f: l.append(i) r.append(i) for i in range(len(l)): l[i] = l[i].strip() r[i] = r[i].strip() for i in range(len(r)): r[i] = r[i].split() for i in range(len(r)): for j in range(len(r[i])): if '1'<=r[i][j][0]<='9': r[i][j] = "{:,}".format(int(r[i][j])) for i in range(len(r)): r[i] = ' '.join(r[i]) for i in r: print(i) #c = "{:,}".format(132) #print(c) f.close() |
6430181421 -> 0.0 -> name 'data' is not defined |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open(data.txt) result = [] for line in f: line.strip() space = [] s = 0 for i in line: if i == ' ': s += 1 else: space.append(s) s = 0 x = line.split() reee = '' for i in range(len(x)): t = [] if x[i][0] != 0 and '123456789': f1 = x[i][-3:] for j in range(3,len(i),3): k = x[i][-j-3:-j] t.append(k) a = t[-1::-1] a.append(f1) re = ','.join(a) if len(space) != i: re += space[i] ree += re else: if len(space) != i: ree += x[i] + space[i] else: ree += x[i] result.append(ree) for i in result: print(i) |
6430236321 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6430327821 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431004221 -> 0.71 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. tempint = "" IamrealLine = "" integers = 0 linearray = [] fin = open("data.txt","r") a = True while a: line = fin.readline() if not line: a = False for ch in line: if ch.isnumeric(): tempint += ch elif (ch == " " or ch == "\n") and tempint != "": integers = int(tempint) if tempint[0] != "0": IamrealLine += str("{:,}".format(integers)) else: IamrealLine += tempint tempint = "" IamrealLine += " " elif not line: a = False else: IamrealLine += ch if tempint != "": if tempint[0] != "0": IamrealLine += str("{:,}".format(integers)) else: IamrealLine += tempint print(IamrealLine) IamrealLine = "" tempint = "" fin.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 A12,345,234 a12,342,212 1,234,567,890,123,456,789,012 is 1,234,567,890,123,456,789,012 |
6431006521 -> 0.0 -> Cannot specify ',' with 's'. |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for line in f: x = line.split() for i in x: if i[0] in '1,2,3,4,5,6,7,8,9': if len(i)>3: i = '{:,}'.format(i) print(x) f.close() |
6431011621 -> 0.71 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def DoMyJob(Str): Round, Result = 0, "" if Str[0] == "0":print(Str) else: for e in Str[::-1]: if Round == 3: Result += "," + e Round = 0 else:Result += e Round += 1 print(Result[::-1], end="") InFile, Data, NowNum, Temp = open("data.txt", "r"), "", False, "" for line in InFile:Data += line InFile.close() for Ch in Data: if Ch.isdecimal(): NowNum = True Temp += Ch else: NowNum = False if Temp:DoMyJob(Temp) Temp = "" print(Ch, end="") if NowNum:print(Temp, end="") |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12,345A234 12,342,212a 1,234,567,890,123,456,789,012 is 123456789012345678901 |
6431012221 -> 0.0 -> string index out of range |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. a = open('data.txt','r') for line in a : alluse = line.strip() alluse[0][2].insert(',') alluse[2][2].insert(',') alluse[4][2].insert(',') a.close() |
6431020221 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt', 'r') for a in f.readlines(): a = a.strip() b = a.split() for i in range(len(b)): try: if b[i][0] != '0': s = "{:,}".format(int(b[i])) b[i] = s except: continue print(" ".join(b)) f.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431021921 -> 0.55 -> invalid literal for int() with base 10: '12345A234' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def read(file_in) : fin = open(file_in, 'r') line = fin.readline() fl = [] while len(line) > 0 : fl.append(line.strip()) line = fin.readline() fin.close() return fl def insertcomma(line) : ns = [] for elem in line.split() : if '1'<= elem[0] <= '9' and len(elem) > 3 : ff = str('{:,}'.format(int(elem))) ns.append(ff) else : ns.append(elem) return ' '.join(ns) fll = read('data.txt') for line in fll : print(insertcomma(line)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 |
6431026021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431028321 -> 0.0 -> invalid syntax (<string>, line 71) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def comma(n) : s = '%d' % n c = [] while s and s[-1].isdigit() : c.append(s[-3:]) s = s([:-3]) return s + ','.join(reversed(c)) out = "" infile = open("data.txt", "w") for data in infile : x = data.split() if 0 <= x <= 9 : if x[0] != 0 : out += comma(x) else : out += x print(out) infile.close() |
6431102021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431105021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431108921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431109521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431110021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431111721 -> 0.0 -> string index out of range |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt","r") for line in fin: x = line.split() for e in x: if e in '0123456789': if int(e[0])!=0: a = '' for j in range(1,len(e)+1): if j%3 == 0: a += ',' else: a += e[j] n = fin close |
6431115221 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. a = open('data.txt') |
6431116921 -> 0.18 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. data = open('data.txt', 'r') y = [] p = '' n = '0123456789' for line in data : y.append(line.strip()) for i in y : for j in i : if j in n : p += j else : p += ' ' p0 = p.split() out = [] for i in p0 : if i[0] != '0' and len(i) > 3: i = int(i) x = format(i,",") i = str(i) p0[p0.index(i)] = x for j in y : y[y.index(j)] = j.replace(i,x) for k in y : print(k) |
99,523,000 plus 989,000 equals 100512000 1 12 123 1,234 1,2345 1,23456 My number is 0894435618 1,234567 1,2345678 1,23456789 1,2345678901,23456789 plus 1,2345678901,234567890 1,2345A234 1,2342212a 1,2345678901,23456789012 is 1,2345678901,2345678901 |
6431118121 -> 0.71 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def thousands_separator(n): n = str(n)[::-1] x = '' for i in range(len(n)): if i%3==0 and i>0: x += ','+n[i] else: x += n[i] return x[::-1] f_in = open('data.txt',"r") for line in f_in: p = line.split() t = '' for i in p: if '0' <= i[0] <= '9': g = thousands_separator(i) t += g+' ' else: t += i+' ' print(t) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0,894,435,618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431119821 -> 0.2 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. x=open('data.txt','r') file='' for line in x : file+=line file1=file.split('\n') ans=[] for k in file1: file2=k.split() for i in file2: if i[0] in '123456789': if 0<len(i)<4: ans.append(i) if 4<= len(i) <=6: i=int(i)/1000 x=str(i).find('.') y=str(i) y1='' for k in y: if k =='.': y1+=',' else: y1+=k ans.append(y1) else: ans.append(i) ans.append('\n') ans2='' for e in ans: if e != '\n': ans2+=e+' ' else: ans2+=e print(ans2) |
plus 989,0 equals 1 12 123 1,234 12,345 123,456 My number is 0894435618 plus is |
6431120321 -> 0.25 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt', "r") for line in fin: x = line.split() for i in x: if "1" <= i[0] <= "9": if 4 <= len(i) <= 6 : u = [] for r in i: u.append(r) u.insert(-3,',') b = "" for o in u: b += o U = x.index(i) x.remove(i) x.insert(U,b) P = "" for e in x: P += e + ' ' print(P) fin.close() |
99523000 plus 989,000 equals 100512000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6431124921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431130621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431132921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431136421 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for line in f: words = line.strip().split(' ') ans = '' for word in words: check = 1 for letter in word: if letter not in '1234567890': check = 0 break if len(word) == 0 or word[0] == '0': check = 0 if check == 1: new_word = '' count = 0 for i in range(len(word)-1, -1, -1): if count == 3: new_word = ',' + new_word count = 0 new_word = word[i]+new_word count += 1 ans += new_word + ' ' else: ans += word + ' ' print(ans) f.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431149621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431211821 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt") for line in fn : x = line.split() listans = [] for e in x : if e.isnumeric() and e[0] != '0': e = e[::-1] ans = '' c = 0 for i in e : if c%3 != 0 : ans += i elif c%3==0: ans +=','+i c += 1 ans = ans[1::] ans = ans[::-1] listans.append(ans) else: listans.append(e) print(" ".join(listans)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431213021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f= open('data.txt') x=[] result=[] num=['0','1','2','3','4','5','6','7','8','9'] for line in f: x=line.split() for i in range(len(x)): #print(x[i][0]) if x[i][0] in num and x[i][0]!='0': result.append(','.join(x[i])) print(result) |
['9,9,5,2,3,0,0,0', '9,8,9,0,0,0', '1,0,0,5,1,2,0,0,0', '1', '1,2', '1,2,3', '1,2,3,4', '1,2,3,4,5', '1,2,3,4,5,6', '1,2,3,4,5,6,7', '1,2,3,4,5,6,7,8', '1,2,3,4,5,6,7,8,9', '1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9', '1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0', '1,2,3,4,5,A,2,3,4', '1,2,3,4,2,2,1,2,a', '1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2', '1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1'] |
6431221021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431225621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431227921 -> 0.0 -> '_io.TextIOWrapper' object has no attribute 'split' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f1 = open('data.txt','w') no = '0123456789' for e in f1.split(): nn = [] if e in no: f1.write(e.insert(-3,',')) for i in range(len(e)-1): if e[i] in no and e[i+1] not in no: f1.write(e[i],' ',e[i+1]) f1.close() |
6431303921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') lines = f.readlines() s = '' for line in lines: s += line line2 = s.replace('\n',' ') line2 = [line2.split()] |
6431305121 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') c = [] for line in f: w = line.split() for i in range(len(w)): if w[i].isnumeric() and w[i][0] != '0': x = str(w[i])[::-1] s = '' for e in range(0, len(x), 3): s += x[e:e+3] + ',' w[i] = s[:-1][::-1] print(' '.join(w)) f.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431307421 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def thousands_separator(n): x = str(n)[::-1] s = "" for i in range(0, len(x), 3): s += x[i:i+3] + "," return s[:-1][::-1] import string fn = open('data.txt') txt = '' array = [] for line in fn.readlines(): txt = line.strip() array.append(txt) final = [] word = '' blank = '' for key in array: l = [] for i in key: if i != ' ' or i in string.digits: word += i if len(blank) != 0: l.append(blank) blank = '' elif i == '\\n': l.append(word) else: if len(word) != 0: l.append(word) word = '' blank += i l.append(word) word = '' final.append(l) for key in final: for i in range(len(key)): if len(key[i]) != 0 and key[i] not in ' ': if key[i][0] in string.digits: if key[i][0] != '0': key[i] = thousands_separator(key[i]) for i in final: print(''.join(i)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431308021 -> 0.37 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. file = open('data.txt') lines = file.readlines() num = '0123456789' lst = [] for line in lines: line = line.rstrip() line = line[::-1] out = '' i = 0 while i < len(line): if i == len(line)-1: if line[i] not in num: out += line[i] break if line[i] in num: for j in range(i+1,len(line)): if line[j] not in num: break if line[j-1] == '0' or j-i<4: out += line[i:j] else: lstt = [] for k in range(i,j,3): lstt.append(line[k:k+3]) out += ','.join(lstt) i = j else: out += line[i] i += 1 lst.append(out) for line in lst: print(line[::-1]) |
99,523,000 plus 989,000 equals 100,512,000 12 123 3 1,234 12,345 123,456 My number is 0894435618 8 1,234,567 12,345,678 123,456,789 234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12,345A234 12,342,212a 234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431309721 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. import string f = open('data.txt','r') for k in f.readlines() : l1 = [] for i in k.split() : n = 0 for j in i : if j in string.digits : n += 1 if n == len(i) and i[0] != '0' : t = len(i) l = [] while True : if t-3 >= 0 : l.append(i[t-3:t]) t -= 3 else : if t == 0 : break else : l.append(i[:t]) break i = ','.join(l[::-1]) l1.append(i) else : l1.append(i) print(' '.join(l1)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431310221 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. with open ("data.txt", "r") as myfile: data=myfile.read() split_data=data.split() for i in split_data : if i.isnumeric() and i[0]!='0' and len(i)>3 : s=[] for j in range(len(i)) : if (j+1)%3==0 and j!=len(i)-1: s.append(list(i[::-1])[j]) s.append(',') else : s.append(list(i[::-1])[j]) new_num=''.join(s[::-1]) split_data[split_data.index(i)]=new_num print(' '.join(split_data)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431311921 -> 0.55 -> invalid literal for int() with base 10: '12345A234' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for i in f: a = i.split() b = "" for j in a: if '1' <= j[0] <= '9': b += str("{:,}".format(int(j))) + ' ' else: b += str(j) + ' ' print(b) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 |
6431312521 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt') text = '' for line in fn: text += line.strip('\n') + ' ' fn.close() text = text[:-1].split(' ') text2 = '' for word in text : try : if word[0] in '123456789' and len(word)>3 : word = '{:,}'.format(int(word)) except : pass text2 = text2 +' '+ word print(text2[1:]) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431313121 -> 0.49 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. data=[] f=open('data.txt','r') for line in f.readlines(): data.append(line.strip()) for each in data: #eachline old=each.split() new=each.split() for wordindex in range(len(new)): #each word done='' if new[wordindex][0].isnumeric() and new[wordindex][0]!='0': count=0 for ch in new[wordindex][::-1]: count+=1 done=ch+done if count%3==0 and count!=len(new[wordindex]): done=','+done else: done=new[wordindex] new[wordindex] = done index = data.index(each) for i in range(len(new)): data[index]=data[index].replace(old[i],new[i]) for line in data: print(line) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 1,2345 1,23456 My number is 0894435618 1,234,567 1,234,5678 1,234,56789 1,234,567,890,123,456,789 plus 1,234,567,890,123,456,7890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431314821 -> 0.74 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. filename = "data.txt" infile = open(filename, 'r') # not yet for line in infile : a = line.strip().split() ans = "" for e in a: if e[0] in "123456789": d = "" for j in range( 0 , len(e) , 1 ): d = e[ len(e) - j - 1 ] + d if ( j + 1 )% 3 == 0 and j != len(e) - 1: d = "," + d ans += d + " " else: ans += e + " " print(ans) infile.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 123,422,12a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431315421 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431316021 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", encoding="utf8") lines = f.read().split("\n") for l in range(len(lines)): w = lines[l].split(" ") for ws in range(len(w)): if w[ws] != "" and w[ws].isdigit() and w[ws][0] != "0": new = w[ws][::-1] wss = [new[i:i+3] for i in range(0,len(new),3)] w[ws] = ",".join(wss)[::-1] lines[l] = " ".join(w) print("\n".join(lines)) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6431329221 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') word = '' for line in f: word += line print(word) f.close() for i,e in enumerate(word): if e >= '1' and e <= '9': do = True num = '' num += e while do: i += 1 if i == len(word): break if word[i] >= '1' and word[i] <= '9': num += word[i] if not(word[i] >= '1' and word[i] <= '9'): if len(num) <= 3: num = num else: num = num[::-1] out = [] for j in range(len(num)//3 + 1): out.append(num[j*3:j*3+3]) print(out) break i += len(e) |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 ['325', '99'] ['325', '9'] ['432', '1'] ['543', '21'] ['543', '2'] ['654', '321', ''] ['654', '32'] ['654', '3'] ['816', '534', '498', ''] ['816', '534', '49'] ['816', '534', '4'] ['816', '534', ''] ['816', '53'] ['816', '5'] ['765', '432', '1'] ['765', '432', ''] ['765', '43'] ['765', '4'] ['876', '543', '21'] ['876', '543', '2'] ['876', '543', ''] ['876', '54'] ['876', '5'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['543', '21'] ['543', '2'] ['212', '243', '21'] ['212', '243', '2'] ['212', '243', ''] ['212', '24'] ['212', '2'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] ['987', '654', '321', ''] ['987', '654', '32'] ['987', '654', '3'] ['987', '654', ''] ['987', '65'] ['987', '6'] |
6431333721 -> 0.0 -> invalid syntax (<string>, line 72) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','w') for line in f: for e in line: if e in ["1","2","3","4","5","6","7","8","9"]: num = True c += 1 else: num = False if num = false f.close() |
6431335021 -> 0.25 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. with open("data.txt", 'r') as f: a = f.readlines() s = "" for e in a: e = e.replace(" ", ".").replace("\n", "").split(".") ccc = False for k in e: ccc = False if len(k) > 0: if k[0] in "1233456789" and len(k) > 3: a = [] for i in range(len(k)): if i == 3: a.append(",") a.append(k[::-1][i]) aa = "".join(a[::-1]) s += aa+" " ccc = True if not ccc: s += k+" " s += "\n" print(s.strip()) |
99523,000 plus 989,000 equals 100512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1234,567 12345,678 123456,789 1234567890123456,789 plus 12345678901234567,890 12345A,234 123422,12a 1234567890123456789,012 is 123456789012345678,901 |
6431344621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. def space(x): out = [] x = x.split() for e in x: k = '' for i in e: if i != ' ': k += i out.append(k) return out fn = open('data.txt','r') for line in fn: l = [] o = space(line) for e in o: if '1' <= e[0] <='9': if len(e) > 3: l.append(e[-len(e):-3:1]+','+e[-3::]) else: l.append(e) print(' '.join(l)) fn.close() |
99523,000 My 1234567890123456,789 1234567890123456789,012 |
6431404621 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431406921 -> 0.0 -> expected an indented block (<string>, line 83) |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. x = open(data.txt,"r") for line in x: |
6431413221 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") A = [] ; B = [] ; BB = [] for line in fn: y = line.split() A.append(y) B0 = [] for i0 in A[0][0]: B0.append(i0) B.append(B0) B2 = [] for i2 in A[0][2]: B2.append(i2) B.append(B2) B4 = [] for i4 in A[0][4]: B4.append(i4) B.append(B4) for i in range(len(B)): if len(B[i]) > 3 : for k in range(1,len(B[i])): if k % 3 ==0: B[i].insert(-k,",") for e in range(len(B)): M = "" for e1 in range(len(B[e])): M += B[e][e1] BB.append(M) A[0][0] = BB[0] A[0][2] = BB[1] A[0][4] = BB[2] print(A[0][0]+" "+A[0][1]+" "+A[0][2]+" "+A[0][3]+" "+A[0][4]) print(A[1][0]+" "+A[1][1]+" "+A[1][2]+" "+A[1][3]) fn.close |
995,23,000 plus 989,000 equals 1005,12,000 1 12 123 1234 |
6431418421 -> 0.0 -> 'str' object has no attribute 'sprit' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. a=open('data.txt','r') for aa in a: x= aa.sprit() for i in range(len(x)): if '0' in x[i] or '1'in x[i] or '2'in x[i] or '3'in x[i] or '4'in x[i] or '5'in x[i] or '6'in x[i] or '7'in x[i] or '8'in x[i] or '9' in x[i]: finish=f"{x[i]:,}" new = a.replace(x[i],finish) b=open('data.txt','w') b.write(new) b.close() a.close() |
6431502421 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. file = open("data.txt","r") file.close() |
6431503021 -> 0.55 -> invalid literal for int() with base 10: '12345A234' |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. file = open("data.txt",'r') line = file.read().split('\n') for i in range(len(line)): nline='' a = line[i].split() for e in a: if '1' <= e[0] <= '9': e = int(e) nline += "{:,}".format(e) + ' ' else: nline += e + ' ' print(nline) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 |
6431505321 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") |
6431516221 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431522021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. print("99,523"+" "+"plus"+"989"+"equals"+" "+"100,512"+" " +"My"+" "+"number"+" "+"is"+" "+"0894435618") |
99,523 plus989equals 100,512 My number is 0894435618 |
6431524221 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt",'r') for i in f: #l = f.readline() for a in i.split(): if a[0] != 0 and a[0] in ['1','2','3','4','5','6','7','8','9']: for e in range(0,len(a),3) : s = a[0:e]+','+a[e:] f.close() |
6431526521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431528821 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') |
6431535121 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. a=[] s="" f=open("data.txt","r") c=0 for i in f: #a=i a.append(i.split(" ")) #print(i.split(" ")) for j in a: for k in j: if k.isdigit=='0': if k[0]=='0': s+=k elif k[0]!='0': s+="," print(s) |
6431541921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431545421 -> 0.0 -> name 'data' is not defined |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. m = open(data.txt,"r") for line in m: # line.split() # for i in line: # if i in print(line) #l1 = m.readline().split #l2 = m.readline() #print() #print(l2) m.close() |
6431701021 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431802721 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6431805621 -> 0.0 -> 'list' object cannot be interpreted as an integer |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. filename = input() file = open(filename) for line in file: x = line.split() for i in range(x): if 999< int(x[i]) < 999999 : x[i] = x[i][0:2] +"," + x[i][3:6] a.append(x[i]) else : a.append(x[i]) file.close() print(a) |
6431808521 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6432023321 -> 0.71 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') def commas(x): x = x[::-1] ret = '' for i in range(len(x)): if i %3 ==0 and i != 0: ret += ',' ret += x[i] return ret[::-1] for line in f: s = '' temp = '' stt = False mstt = False for i in line[:-1]: if ord(i)==ord('0') and not stt: mstt = True if i == ' ': mstt = False if 1 <= ord(i) - ord('0') <= 9 and not stt and not mstt: stt = True elif not (0 <= ord(i) - ord('0') <= 9) and stt and not mstt: stt = False s += commas(temp) temp = '' if not stt: s += i if stt: temp += i if temp != '': s += commas(temp) print(s) f.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12,345A234 12,342,212a 1,234,567,890,123,456,789,012 is 12,345,678,901,234,567,890 |
6432045121 -> 0.0 -> name 'lin' is not defined |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt","r") line = fin.read() while len(line) > 0: data = lin.split() |
6432071421 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. data = open('data.txt', 'r') for line in data.readlines(): line = line.strip() if len(line) != '': line = line[::-1] i = 0 answer = '' while i < len(line): if line[i].isnumeric() == False: answer += line[i] i += 1 continue j = i first = '' while j < len(line) and line[j].isnumeric() == True: first = line[j] j += 1 if first == '0': while i < len(line) and line[i].isnumeric() == True: answer += line[i] i += 1 else: count = 0 while i < len(line) and line[i].isnumeric() == True: count += 1 answer += line[i] if count % 3 == 0 and i != len(line) - 1 and line[i + 1].isnumeric() == True: answer +=',' i += 1 print(answer[::-1]) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12,345A234 12,342,212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6432077221 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", "r") txt = f.readline() while txt != '': word = txt.split() space = [] combo = 0 for i in range(len(txt)): if txt[i] == ' ': combo += 1 elif combo>0: space.append(combo) combo = 0 def addcomma(x): res = '' x = x[::-1] for i in range(len(x)): if i%3 == 0 and i>0: res += ',' res += x[i] res = res[::-1] return res for i in range(len(word)): x = word[i] if x.isnumeric() and x[0] != '0': word[i] = addcomma(x) for i in range(len(word)): print(word[i], end='') if i < len(space): for j in range(space[i]): print(' ', end='') print('') txt = f.readline() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6432083021 -> 1.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f=open('data.txt','r') for j in f.read().splitlines(): l=[] s='' # print(j) for k in j: if k !=' ': s+=k else: l.append(s) s='' l.append(s) # print(l) for i in l: if i.isnumeric() and i[0]!='0': print("{:,}".format(int(i)),end=' ') else: print(i,end=' ') print() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6432086921 -> 0.0 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. |
6432090321 -> 0.55 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') ans = [] for line in f: x = line.split(' ') a = '' for j in x: if j == '': a += ' ' elif j[0] >= '1' and j[0] <= '9': c = 0 l = len(j)-1 t = '' for i in range(len(j)): t += j[i] if (l-i)%3 == 0 and i != l: t += ',' a += t + ' ' else: a += j + ' ' ans.append(a) f.close() for i in ans: for j in range(len(i)): if j != len(i)-1: print(i[j], end = '') |
99,523,000 plus 989,000 equals 1,005,120,00 1 12 123 1,234 12,345 1,234,56 My number is 0894435618 1,234,567 12,345,678 1,234,567,89 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 123,45A,234 1,234,221,2a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6432101621 -> 0.2 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') content = f.readlines() f.close() line = str(content[0]).strip() line1 = content[1] output = 0 check = content[0].strip() for i in check.split(): output = '' if i.isnumeric() == True and len(i)>3: for j in range(len(i)): output = i[len(i)-1-j] + output if (j-2)%3 == 0: output = ',' + output output = output.strip(",") line = line.replace(i,output) print(line) print(line1) |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1234 12345 123456 |
6432179621 -> 0.8 -> |
# Adding_commas (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt") for line in fn : data = line.split() ans = [] for e in data: if e[0] != "0" and e.upper() == e.lower(): word = "" for i in range(-1,-len(e)-1,-1): word = e[i] + word if i%3 == 0 and i != -len(e): word = "," + word ans.append(word) else: ans.append(e) print(" ".join(ans)) fn.close() |
99,523,000 plus 989,000 equals 100,512,000 1 12 123 1,234 12,345 123,456 My number is 0894435618 1,234,567 12,345,678 123,456,789 1,234,567,890,123,456,789 plus 12,345,678,901,234,567,890 12345A234 12342212a 1,234,567,890,123,456,789,012 is 123,456,789,012,345,678,901 |
6130084421 -> 0.0 -> name 'a' is not defined |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt', 'r') for line in f: ans = '' x = [] for e in line: x.append(e) i = 1 for i in range(1,len(x)-1): if ('A'<=x[i]<='Z' and 'A'<=x[i+1]<='Z') or ('A'<=x[i]<='Z' and 'A'<=x[i-1]<='Z'): ans += x[i-1]+x[i]+'-' i += 1 else: ans += a[i] f.close() |
6130443021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6130445321 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6130522021 -> 0.0 -> expected an indented block (<string>, line 82) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f=open("data.txt", "r") for line in f: a=a.split(" ") ans="" for i in a: if (len (i))>2: if i.upper()==i: |
6231415321 -> 0.8 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt") check = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" wordCheck = False for line in f : data = line.strip().split() for i in range (len(data)) : for alp in data[i] : if alp not in check : wordCheck = False break wordCheck = True if wordCheck : word = "" count = 0 for j in data[i] : if count != 2 : word += j count += 1 else : word += "-" + j count=1 data[i] = word print(" ".join(data)) f.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6231503921 -> 0.0 -> string index out of range |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f1=open("data.txt",'r') s='' for line in f1: for i in range(0,len(line),2): if line[i:i+2].isupper() and line[i+3].isupper() : s+=line[i:i+2]+'-' else : s+=line[i:i+2] print(s) |
6330016521 -> 0.58 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin=open("data.txt",'r') line=''; c=0 for l in fin: for s in l: if 'A'<=s<='Z': c+=1 else: c=0 line+=s if c==2: line+='-' c=0 print(line) line='' fin.close |
PY-TH-ON-IS-TA- and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP- T 100 songs I use LO-GI-TE-C LO-G100 LG-100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY- UN-VI-ER-SI-TY- and I am CU-104 Earth is 4543000 YE-AR-S old |
6330039021 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt', 'r') new = "" out = "" result = [] for line in f: s = line.split() for e in s: if e.upper() == e and len(e) > 2: for i in range(0,len(e),2): if e[i:i+2] != e[-2:]: new += e[i:i+2] + "-" else: new += e[i:i+2] if new[-1] == "-": new = new[:-1:] out += " " + new new = "" else: out += " " + e result.append(out.strip()) out = "" f.close() for k in result: print(k) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-000 YE-AR-S old |
6330107021 -> 0.29 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt",'r',encoding='utf-8') file = f.read() myString = file.split() for i in range(len(myString)): word = myString[i] if word == word.upper(): newWord = '' for j in range(len(word)): letter = word[j] if (j+1)%3==0: newWord += '-' + letter else: newWord += letter myString[i] = newWord for i in myString: print(i,end=' ') |
PY-THO-NIS-TA and CPLUSplus are very PO-PUL-AR BI-LLB-OAR-D TO-P TP T 10-0 songs I use LO-GIT-EC LO-G10-0 LG-100 L1-00 mouse CH-ULA-LON-GKO-RN is MY UN-VIE-RSI-TY and I am CU-104 Earth is 45-430-00 YE-ARS old |
6330234021 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def dash(x) : y = '' for i in range(0,len(x),2) : y += x[i:i+2] + '-' return y[:-1] fn = open( "data.txt" , 'r' ) for line in fn : y = '' x = line.split() for e in x : if 'A' <= e[1:] <= 'Z' : y += dash(e) + ' ' else : y += e + ' ' print(y) fn.close() |
PY-TH-ON-IS-TA and CP-LU-Sp-lu-s are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6330375821 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. x = '' infile = open('data.txt', 'r') for line in infile: Char = line.strip().split() #[Char] for i in Char: if 'A'<= i <= 'Z' : x += '-'.join(''.join(p) for p in zip(*[iter(i)]*2)) else: x += ' '+i + ' ' infile.close() print(x) |
PY-TH-ON-IS-TA and CP-LU-Sp-lu are very PO-PU-LABI-LL-BO-ARTOTP 100 songs use LO-GI-TELO-G1-00LG-10L1-00 mouse CH-UL-AL-ON-GK-OR is MYUN-VI-ER-SI-TY and am CU-10Ea-rt is 4543000 YE-AR old |
6330586921 -> 0.0 -> name 'file' is not defined |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. a = "" for line in file : a += line.strip() a += "\n" file.close() print(a) |
6331512621 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") for k in range(3): line = fn.readline() x = line.split() for j in x: if "A-Z" in j: '-'.join(j) fn.close() |
6331518421 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6332026121 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn=open("data.txt","r") line = fn.readline() while len(line) > 0: ans = "" c=0 while c<=(len(line)-1): if(line[c]=="\n"): break elif(line[c]==" "): ans += line[c] elif(line[c].isupper() and line[c+1].isupper() and line[c+2].isupper()): ans += line[c]+line[c+1]+"-" c+=2 #print("xxx") continue else: ans += line[c] c+=1 print(ans) line = fn.readline() fn.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430001121 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", 'r') line = f.readline() while len(line) >= 1: for i in range(len(line)): #print(line[i:i+4]) if line[i].isupper() and line[i+1].isupper() and line[i+2].isupper() and line[i+3].isupper(): line = line[:i+2] + '-' + line[i+2:] elif line[i].isupper() and line[i+1].isupper() and line[i+2].isupper(): line = line[:i+2] + '-' + line[i+2:] print(line.strip()) line = f.readline() f.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PULAR BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430003421 -> 0.22 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def read_line_to_list(file_name): f = open(file_name, "r") lines = list(f) #= f.readlines() for s in range(len(lines)): if lines[s][-1] == "\n": lines[s] = lines[s][:-1:] f.close() return lines# list of lines that each one has no "\n" lines = read_line_to_list("data.txt") each_line = [t.split(r'(\s+)') for t in lines]#[txt.split() for txt in lines]#list of list for lin in range(len(each_line)): for txt in range(len(each_line[lin])): if each_line[lin][txt] == each_line[lin][txt].upper() and " " not in each_line[lin][txt]:#ex LOGITEC k = each_line[lin][txt] n = len(k) m = "-".join([ k[i:i+2] for i in range(0,n,2)]) each_line[lin][txt] = m else: pass lines1 = [" ".join(each_line[i]) for i in range(len(each_line))] print("\n".join(lines1)) |
PYTHONISTA and CPLUSplus are very POPULAR BILLBOARD TOP TP T 100 songs I use LOGITEC LOG100 LG100 L100 mouse CHULALONGKORN is MY UNVIERSITY and I am CU104 Earth is 4543000 YEARS old |
6430007021 -> 0.0 -> join() takes exactly one argument (0 given) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", 'r') for line in f: x = line.split() for e in x: if len(e)>2 and 'A'<=e[-1]<='Z': for i in range(len(e)): if i%2 == 0 and i != 0: e = e[:i]+'-'+e[i:] for e in x: e.join() f.close() |
6430013721 -> 0.0 -> not writable |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. op = open("data.txt","r") wo = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' i = 0 for line in op : while i <= len(line): if line[i] and line[i+1] and line[i+2]in wo: op.write(line[i]+line[i+1]+'-') i += 2 for line in op : print(line) op.close() |
6430015021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. data = open("data.txt","r",encoding='utf-8') line = data.readline() ans = [] for line in data : for e in line : com = e.split() for i in com : for j in i : if j.istitle() == False : new = i break else : new = "" w = 0 while w <= len(i) : if w == 0 : new += i[:2] w += 2 continue if len(i) - w < 2 : new += "-" + i[w:] w += 2 continue new += "-" + i[w:w+2] w += 2 ans.append(i.strip()) print(" ".join(ans)) data.close() |
B I L L B O A R D D T O P P T P P T T 1 0 0 0 s o n g s s B I L L B O A R D D T O P P T P P T T 1 0 0 0 s o n g s s I I u s e e L O G I T E C C L O G 1 0 0 0 L G 1 0 0 0 L 1 0 0 0 m o u s e e B I L L B O A R D D T O P P T P P T T 1 0 0 0 s o n g s s I I u s e e L O G I T E C C L O G 1 0 0 0 L G 1 0 0 0 L 1 0 0 0 m o u s e e C H U L A L O N G K O R N N i s s M Y Y U N V I E R S I T Y Y a n d d I I a m m C U 1 0 4 4 B I L L B O A R D D T O P P T P P T T 1 0 0 0 s o n g s s I I u s e e L O G I T E C C L O G 1 0 0 0 L G 1 0 0 0 L 1 0 0 0 m o u s e e C H U L A L O N G K O R N N i s s M Y Y U N V I E R S I T Y Y a n d d I I a m m C U 1 0 4 4 E a r t h h i s s 4 5 4 3 0 0 0 0 Y E A R S S o l d |
6430016621 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430017221 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430018921 -> 0.0 -> I/O operation on closed file. |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. with open("data.txt","r") as file: lines = [] for line in file: spilt_line = line.split() if spilt_line[0].isupper(): line.append(spilt_line[0][:-1] + "-" + spilt_line[1:]) else: lines.append(line) file.close() |
6430021721 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fo = open('data.txt', 'r') file = fo.read().strip() title = file.split('\n') fo.close() for e in range (len(title)): word = title[e].split(' ') for i in range (len(word)): check = word[i].isupper() if check == True: word[i] = '-'.join(word[i][k:k+2] for k in range(0, len(word[i]), 2)) print(word[i],end=' ') elif word[i] == '': print(' ',end='') else: print(word[i] ,end=' ') print('\n') |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6430026921 -> 0.0 -> 'str' object does not support item assignment |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin = open( "data.txt" , "r" ) for line in fin: line = fin.readline() for i in range(len(line)) : if line[i+1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : line[i] += "-" fin.close() |
6430029821 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430035521 -> 0.0 -> list indices must be integers or slices, not str |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. n = 3 fin = open("data.txt", "r") for k in range(n): line = fin.readline() x = line.split() fin.close() for i in x: if x[i] == x.upper: x[i][i].insert(x[i][1::2],"-") print(x) |
6430037821 -> 0.8 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def checkalp(word) : al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in word : if i not in al : return False return True def adddash(word) : a = "" n = 0 for i in word : if n !=0 and n%2 == 0 : a += "-"+i else : a += i n+=1 return a dt = open("data.txt","r") for line in dt : lis = line.split(" ") for i in range(len(lis)) : if checkalp(lis[i]) : lis[i] = adddash(lis[i]) if lis[-1][-1] == "\n" : lis[-1] = lis[-1][:-1] print(" ".join(lis)) dt.close() |
PY-TH-ON-IS-TA and CPLUSplus are very POPULAR BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430043521 -> 0.51 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt', 'r') for line in fn: out = '' ; ans = '' for w in line: out += w for i in range(0,len(out),2): if out[i] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and out[i+1] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and out[i+2] != ' ': ans += out[i] + out[i+1] + '-' else: if i+1 < len(out): ans += out[i] + out[i+1] else: ans += out[-1] print(ans) fn.close() |
PY-TH-ON-IS-TA and CPL-US-plus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-104 Earth is 4543000 YEA-RS old |
6430045821 -> 0.0 -> string index out of range |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. filein = open(input(), "r") for line in filein : line = line.strip() i = 0 out = "" while i < len(line) : if line[i] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : if line[i+1] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : if line[i+2] != " " : out += line[i] + line[i+1] + "-" i += 1 else : out += line[i] else : out += line[i] else : out += line[i] i += 1 print(out) |
6430046421 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430048721 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # |
6430049321 -> 0.07 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def read_file(filename): fo = open(filename) file = fo.readlines() for e in file: for i in range(0,len(e)-2): if 'A'<=e[i]<='Z' and 'A'<=e[i+2]<='Z': e = e[:i+2]+'-'+e[i+2:] print(e, end='') fo.close() return file file1 = read_file('data.txt') |
PY--TH--ON--IS--TA and CP--LU--Splus are very POPULAR BI--LL--BO--AR--D -TO--P -TP T 100 songs I use LO--GI--TE--C -LO--G100 LG100 L100 mouse CH--UL--AL--ON--GK--OR--N is MY -UN--VI--ER--SITY and I am CU104 Earth is 4543000 YE--AR--S old |
6430052121 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt' , 'r') x = f.readlines() for sentence in x : for j in range(len(sentence)) : if 'A' <= sentence[j] <= 'Z' and 'A' <= sentence[j-1] < 'Z' and sentence[j+1] != ' ': sentence = sentence[0:j+1] + '-' +sentence[j+1:] print(sentence) f.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PULAR BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG-100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430054421 -> 0.36 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin= open("data.txt", "r") r="" ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ" n=0 for line in fin: for c in line: if c in ALP: n+=1 elif c not in ALP: n==0 if n==2 and c!=" ": r+=c+"-" n=0 else: r+=c print(r) fin.close() |
PY-TH-ON-IS-TA- and CP-LU-Splus are very P-OP-UL-AR- BI-LL-BO-AR-D T-OP- TP- T 100 songs I- use LO-GI-TE-C L-OG-100 LG-100 L100 mouse C-HU-LA-LO-NG-KO-RN- is MY- UN-VI-ER-SI-TY- and I am C-U104 E-arth is 4543000 YE-AR-S old |
6430055021 -> 0.8 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. rd = open("data.txt","r") data = [] for line in rd: data.append(line) rd.close() uset = [] re = [] for word in data: sp = word.split() for text in sp: upper = True for alp in text: if "A" <= alp <= "Z" : pass else: upper = False if upper: s = "" if len(text) % 2 == 0: for q in range(0,len(text)-1,2): s += text[q] s += text[q+1] s += "-" s = s[:-1:] else: for q in range(0,len(text)-1,2): s += text[q] s += text[q+1] s += "-" s += text[-1] uset.append(text) re.append(s) newdata = [] for word2 in data: p = word2.split() for use in range(len(p)): if p[use] in uset: index = uset.index(p[use]) p[use] = re[index] newdata.append(p) for t in newdata: a = " ".join(t) print(a) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430059621 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. a=open('data.txt','r') Lines = a.readlines() for i in Lines: x=list(i) for j in range(len(x)): if x[j].isupper(): j+=1 if x[j].isupper() and x[j+1].isupper(): x.insert(j+1,'-') j+=1 if '\n' in x: print(''.join(x[0:len(x)-1])) else: print(''.join(x)) a.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PULAR BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430064721 -> 0.0 -> invalid syntax (<string>, line 62) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin = open(data.txt , "r") for line in fin : line = line.split() for x in line : if x isupper(): for i in range(len(x)-1) : new = x[i]+x[i+1] + "-" |
6430068221 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt',"r") cap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for line in fin: n = line t = "" for ch in line: if (len(t) == 0) or (len(t)==1): t+=ch elif (ch in cap) and (t[-1] in cap) and (t[-2] in cap) : t += '-' + ch else: t+= ch print(t) fin.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430069921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430079121 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. s = input().split() u = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ans = [] for i in range(len(s)): for j in range(len(s[i])): if s[i] in u: if j >2 : ans.append(s[i]) s = input() s = input() for i in range(len(ans)): print('-'.join(ans[i][0::2])) |
6430081321 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. data = open("data.txt","r") d = [] g = "" x = data.readline() while len(x) != 0 : t = x.split() for e in t : if e == e.upper() : for i in range(0,len(e),2) : if i == len(e) - 1 : s = e[i] else : s = e[i] + e[i+1] if i != len(e) -1 and i + 1 != len(e) - 1 : s += "-" g += s d.append(g) g = "" else : d.append(e) x = data.readline() data.close() word = (" ").join(d) print(word) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6430082021 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. for e in open("data.txt", "r"): s = "" count = 0 c = e.strip() + "*" for i in range(len(c) - 1): if c[i].isupper() and c[i + 1].isupper(): count += 1 else: count = 0 s += c[i] if count % 2 == 0 and count > 0: s += "-" count = 0 print(s) |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430085921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. upper = "ABCDEFGHIJKLMNOPQRSTUWXYZ" fin = open("data.txt", "r") line = fin.readline() fin.close() print() |
6430088821 -> 0.2 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file = open("data.txt","r") for e in file: space = str() temp = e.split() s = [] for i in range(len(e)-2): if e[i] == " ": space += e[i] if e[i+1] != " ": s.append(space) space = str() new = [] for j in temp: if j == j.upper(): i = 0 line = str() for k in range(len(j)): if i == 2: i = 0 line += "-" line += j[k] i+=1 new.append(line) else: new.append(j) a = str() for i in range(len(new)-1): a += new[i] + s[i] a += new[-1] print(a) file.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6430090021 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. with open('data.txt', 'r') as file: lines = file.readlines() out = [] for line in lines: cntr = 0 lline = '' for chara in line: if chara.isalpha() and chara == chara.upper(): if cntr >= 2: cntr = 0 lline += '-' cntr += 1 else: cntr = 0 lline += chara out += lline for i in out: print(i,end='') |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430093921 -> 0.8 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file = open('data.txt', 'r') for line in file: word = line.split(' ') nw = [] for e in word: up = True for c in e: if 'A' <= c <= 'Z': pass else: up = False if up: ne = '' for i in range(0,len(e),2): ne += e[i:i+2] + '-' nw.append(ne[0:-1:]) else: nw.append(e) nl = [] for m in nw: if m == '': nl[-1] += ' ' elif '\n'in m: nl.append(m[0:-1]) else: nl.append(m) print(' '.join(nl)) file.close() |
PY-TH-ON-IS-TA and CPLUSplus are very POPULAR BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430094521 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430099721 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. from itertools import zip_longest with open("data.txt") as file: lines = file.readlines() for i, line in enumerate(lines): for string in line.split(): if string.isupper(): lines[i] = lines[i].replace(string, '-'.join(a+b for a,b in zip_longest(string[::2], string[1::2], fillvalue=""))) print("".join(lines)) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6430102921 -> 0.44 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") line_list = [] for line in fn : line_list.append(line) fn.close() s = "".join(line_list) out = "" for i in range(0,len(s)-1,2) : if "A" <= s[i] <= "Z" and "A" <= s[i+1] <= "Z" and s[i+2] != " ": out += s[i] + s[i+1] + "-" else : out += s[i] + s[i+1] out += s[-1] print(out) |
PY-TH-ON-IS-TA and CPL-US-plus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LOG-IT-EC LOG-100 LG-100 L100 mouse CHU-LA-LO-NG-KO-RN is MY UNV-IE-RS-IT-Y and I am CU104 Earth is 4543000 YE-AR-S old |
6430105821 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430107021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430110921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fp = open("data.txt","r",encoding="utf-8") uppertext= "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".split() count = 0 for x in fp: for y in x: if y in uppertext: if count == 2: print("-",end="\0") count = 0 print(y,end="\0") count+=1 else: count = 0 print(y,end="\0") fp.close() |
P Y - T H - O N - I S - T A a n d C P - L U - S p l u s a r e v e r y P O - P U - L A - R B I - L L - B O - A R - D T O - P T P T 1 0 0 s o n g s I u s e L O - G I - T E - C L O - G 1 0 0 L G 1 0 0 L 1 0 0 m o u s e C H - U L - A L - O N - G K - O R - N i s M Y U N - V I - E R - S I - T Y a n d I a m C U 1 0 4 E a r t h i s 4 5 4 3 0 0 0 Y E - A R - S o l d |
6430113821 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def countspace(line): x = [] found = False t = '' for i in range(len(line)-1): if line[i] == ' ': found = True t += ' ' if (found == True) and line[i+1] != ' ' : x.append(t) found = False t = '' return x f = open("data.txt","r") for line in f: new = [] words = line.split() for w in words: if w == w.upper(): t='' count = 0 for a in w: if count !=2: t += a count += 1 else: t+= '-'+a count = 1 else: t = w new.append(t) sp = countspace(line) for i in range(len(sp)): new[i]+=sp[i] print("".join(new)) f.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6430114421 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430121821 -> 0.0 -> object of type '_io.TextIOWrapper' has no len() |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt") a = len(f) res = "" for l in f: z = l for i in l.split(): if i.isupper(): x = "" for j in range(len(i)): if j%2 == 0: x += "-" x += i[j] z = z.replace(i,x.strip("-")) res += z print(res) |
6430122421 -> 0.68 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt') c = 0 out = '' ans = [] for line in fn: for e in range(len(line.strip())): out += line[e] if 'A'<= line[e] <='Z': c+= 1 if line[e] == ' ': c = 0 if c == 2 and line[e+1] != ' ': out += '-' c = 0 ans.append(out) out = '' for i in ans: print(i) fn.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R B-IL-LB-OA-RD TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG-100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-104 Earth is 4543000 YE-AR-S old |
6430123021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430126021 -> 0.0 -> invalid syntax (<string>, line 66) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt","r") fin = ["PYTHON is very popular","I use LOGITEC mouse","CHULALONGKORN is MY University"] ans = [] for line in fin : d = list(str(line)) x = "" c = 1 for i in range(0,len(d)-3) : if 'A'<=d[i]<='Z' and 'A'<=d[i+1]<='Z'and c=1 : if 'A'<=d[i+2]<='Z' and 'A'<=d[i+3]<='Z' : x+=(str(d[i:i+2])+"-"+str(d[i+2:i+4])) c = 0 ans+=[d] print(ans) |
6430127621 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. x = 'data.txt' f1 = open(x) out = '' for y in f1 : out = '' line = y.strip().split() for e in line : if e == e.upper() : for i in range(len(e)) : if i %2 == 0 or i+1 == len(e): out += e[i] else : out += e[i] + '-' else : out += e out += ' ' print(out) out = '' |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6430128221 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430130421 -> 0.0 -> list index out of range |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt','r') Data=[] for i in fin: if i[-1] == '\n' : Data.append(i[:-1:].split()) else: Data.append(i.split()) fin.close() fin = open('data.txt','r') Data1=[] for i in fin: if i[-1] == '\n' : Data1.append(i[:-1:]) else: Data1.append(i) fin.close() Blank=[] for i in Data1: n=0 L=[] for j in i: if j==' ': n+=1 else: if n != 0: L.append(n) n=0 Blank.append(L) print(Blank) for i in range(len(Data)): for j in range(len(Data[i])) : if Data[i][j] == (Data[i][j].upper()): if len(Data[i][j]) > 2 : s='' n=0 for k in range(len(Data[i][j])): s+=Data[i][j][k] n+=1 if (n == 2) and (k+1 != len(Data[i][j])): s+='-' n=0 Data[i][j] = s+(' '*Blank[i][j]) for i in Data: p='' for j in i : p+= j+' ' print(p) |
[[1, 5, 4, 1, 8], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1]] |
6430131021 -> 0.68 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt",'r') for line in f: c = 0 ans = '' for i in range(len(line)): if line[i] in 'ABCDEFGHIJKLMNOPQRSTUYWXYZ': c += 1 ans += line[i] else : c = 0 ans += line[i] if c == 2 and line[i+1] != ' ' : ans += '-' c = 0 if ans[-1] == '\n': print(ans[:-1]) else: print(ans) f.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG-100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VIE-RS-IT-Y and I am CU-104 Earth is 4543000 YE-AR-S old |
6430137921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430139121 -> 0.0 -> unexpected indent (<string>, line 68) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for i in f: a = list(i) f = 0 for e in range(len(a)): if ('A' <= a[e] <= 'Z') and ('A' <= a[e+1] <= 'Z') and ('A' <= a[e+2] <= 'Z'): f += e break f.close() v = a[f::] f1 = v.index(' ') ac = [] for g in range(len(v[:f1])): if g == len(v[:f1])-1: ac.append(v[:f1][g]) elif g%2 != 0: ac.append(v[:f1][g]) ac.append('-') else: ac.append(v[:f1][g]) l = a.index(ac[-1]) final = a[:f] + ac[0::] + a[l+1::] print(''.join(final)) |
6430143621 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430144221 -> 0.2 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt", "r") a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for line in infile : x = line.strip().split() for i in x : c = "" if len(i) > 2 : for k in range(len(i)-1) : if i[k] in a : c += i[k]+i[k+1]+"-" else : c += i[k] else : c += i print(c) |
PY-YT-TH-HO-ON-NI-IS-ST-TA- an CP-PL-LU-US-Sp-plu ar ver PO-OP-PU-UL-LA-AR- BI-IL-LL-LB-BO-OA-AR-RD- TO-OP- TP T 10 song I us LO-OG-GI-IT-TE-EC- LO-OG-G1-10 LG-G1-10 L1-10 mous CH-HU-UL-LA-AL-LO-ON-NG-GK-KO-OR-RN- is MY UN-NV-VI-IE-ER-RS-SI-IT-TY- an I am CU-U1-10 Ea-art is 454300 YE-EA-AR-RS- ol |
6430146521 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. x = open('data.txt') data=[] for i in x: if i[-1]=="\n": data.append(i[:-1]) else: data.append(i) x.close() outdata=[] for line in data: out=line for i in range (len(out)): for i in range(len(out)): if i<=1: pass else: if out[i-2] in "ABCDEJGHIJKLMNOPQRSTUVWXYZ" and out[i-1] in "ABCDEJGHIJKLMNOPQRSTUVWXYZ" and out[i]in "ABCDEJGHIJKLMNOPQRSTUVWXYZ": out=out[:i]+"-"+out[i:] outdata.append(out) for i in outdata: print(i) |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430147121 -> 0.0 -> empty separator |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for line in f: words=line.strip().split('') ans='' for word in work: if word.upper()==word: tmp=0 for letter in word: ans+=letter if tmp ==1: ans+='-' tmp=0 else: tmp=1 if ans[-1]=='-': ans=ans[:-1] else: ans+=word ans+='' print(ans) f.close() |
6430149421 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6430151621 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') a = [] for i in f: a.append(i) f.close() def put_dat(lst): result = ['-'] * (len(lst) * 2 - 1) result[0::2] = lst return result def space(word): als = [word[index : index + 2] for index in range(0, len(word), 2)] return ''.join(put_dat(als)) output = [] for i in a: sentenses = i words = i.split() for j in words: if j == j.upper(): new_word = space(j) sentenses = sentenses.replace(j,new_word) output.append(sentenses) for i in output: print(i,end='') |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6430152221 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f=open("data.txt","r") for i in f: x=i.strip() c=x[0] e=0 for j in range(1,len(x)): c+=x[j] k=j+e if "A"<=c[k]<="Z" and "A"<=c[k-1]<="Z" and "A"<=x[j+1]<="Z": c+="-" e+=1 print(c) f.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6430155121 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. cap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" infile = open('data.txt') ans='' for line in infile: for i in range(0,len(line)-1,2): if line[i] in cap and line[i+1] in cap: ans += line[i:i+2] ans += '-' elif line[i] in cap and line[i+1] not in cap: ans += line[i:i+2] infile.close() print(ans) |
PY-TH-ON-IS-TA-PL-US-PO-PU-LA-R BI-LL-BO-AR-D TO-P TP-I LO-GI-TE-C LO-G1G1CH-UL-AL-ON-GK-OR-N Y UN-VI-ER-SI-TY-CU-EaEA-RS- |
6430161921 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file = open('data.txt', 'r') for i in file: word = i.split() final = '' for k in word: if k.upper() == k and len(k) > 2: alph = list(k) stra = '' for l in range(0, len(alph)+3, 3): alph.insert(l+2, '-') for m in alph: stra += m if stra[-1] == '-': stra = stra[0:-1] final += stra + ' ' else: final += k + ' ' print(final) file.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00- mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6431002021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431005921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. a = "CHULALONGKORN is MY university" ans = "" for word in a.split(): check = word.isupper() if check == True: b = '-'.join(word[i:i+2] for i in range(0, len(word), 2)) ans = ans + " " + b else: ans = ans + " " + word print(ans) |
CH-UL-AL-ON-GK-OR-N is MY university |
6431007121 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431008821 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. a = input().split() b = sorted(a) c = b[0] key = "-" d1 = c[0:2] d2 = c[2:4] d3 = c[4:6] d4 = c[6:8] d5 = c[8:10] d6 = c[10:12] d7 = c[12:14] if 4 > len(b[0]) > 2 : big = d1 + key + d2 elif 6 > len(b[0]) > 4 : big = d1 + key + d2 + key + d3 elif 8 > len(b[0]) > 6 : big = d1 + key + d2 + key + d3 + key + d4 elif 10 > len(b[0]) > 8 : big = d1 + key + d2 + key + d3 + key + d4 + key + d5 elif 12 > len(b[0]) > 10 : big = d1 + key + d2 + key + d3 + key + d4 + key + d5 + key + d6 elif len(b[0]) > 12 : big = d1 + key + d2 + key + d3 + key + d4 + key + d5 + key + d6 + key +d7 |
6431010021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431014521 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431019721 -> 0.0 -> name 'file_in' is not defined |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. infile = open(file_in, "r") word = [] n = [] ans = "" last = "" for line in infile: #PYTHON is very popular\n for e in line: if e in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','T','U','V','W','X','Y','Z']: word.append(e) for d in word: n.append(d[0::2]) nword = "-".join(n) else: ans infile.close() |
6431024821 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def main(): search = open("data.txt", "r", encoding="utf8") for i in search.readlines(): i = i.replace("\n", "") data, li1 = i.split(), [] for j in data: if j.isupper() and len(j) > 2: test = "" for x in range(len(j)): if x != 0 and (x) % 2 == 0: test += "-" + j[x] else: test += j[x] li1.append([j, test]) for p in li1: i = i.replace(p[0], p[1]) print(i) main() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6431027721 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431103721 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431104321 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for line in f: words = line.strip().split(' ') ans = '' for word in words: if word.upper() == word: tmp = 0 for letter in word: ans += letter if tmp == 1: ans += '-' tmp = 0 else: tmp = 1 if ans[-1] == '-': ans = ans[:-1] else: ans += word ans += ' ' print(ans) f.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6431112321 -> 0.0 -> name 'data' is not defined |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn = open(data.txt, r) x = [] for i in fn : if fn[i:i+2] in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": x.append(fn[i:i+1]) x.append("-") else : x += fn[i] fn.close() |
6431121021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. data = open("data.txt") line = "" A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for line in data: for e in line: if e in A: line += e[::2] + '-' print(line) |
Earth is 4543000 YEARS oldE-Y-E-A-R-S- |
6431122621 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def dash(word) : new = '' for ch in word: if len(new) % 3 == 0: new += '-' new += ch return new[1:] f = open("data.txt", 'r') out = '' for line in f : for j in line.split() : for k in j : if k.islower() : new = j break new = dash(j) out += new + ' ' out += '\n' print(out) f.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6431134121 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431139321 -> 0.73 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. def com(a) : k = '' b = a.split() for i in b : y = '' h = '' for e in i: if 'A' <= e <= 'Z': y += e if 'A' <= e <= 'Z' or 'a' <= e <= 'z' or e == ' ' or e in ['0','1','2','3','4','5','6','7','8','9'] : h += e if len(y) == len(i) : g = y[0:2] for m in y[2::]: if '-' not in g[-2:]: g += '-' g += m else: g += m k += g k+= ' ' else : k += h k+= ' ' return k a = open('data.txt','r') k = [] for i in a : k.append(i) y = [] m = [] for i in k : y.append(i[0:-1]) for i in y: s = com(i) m.append(s) for i in m : print(i) a.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S ol |
6431140921 -> 0.0 -> name 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' is not defined |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. a = [ABCDEFGHIJKLMNOPQRSTUVWXYZ] data = open('data.txt','r') for line in data : n = line.split() for i in n : if len(i) > 2 : n = i data.close() |
6431201521 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') ans1 = '' for line in f: ans = line for i in line.split(): if i.isupper(): t = '' for j in range(len(i)): if j%2==0: t += '-' t += i[j] ans = ans.replace(i,t.strip('-')) ans1 += ans print(ans1) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6431205021 -> 0.58 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. a = '' count = 0 file = open('data.txt', 'r') for line in file: for c in line: if 'A' <= c <='Z': count += 1 a += c else: a+=c if c == ' ': count = 0 elif count == 2: a += '-' count = 0 file.close print(a) |
PY-TH-ON-IS-TA- and CP-LU-Splus are very PO-PU-LA-R B-IL-LB-OA-RD- TO-P TP- T 100 songs I use LO-GI-TE-C LO-G100 LG-100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY- UN-VI-ER-SI-TY- and I am CU-104 Earth is 4543000 YE-AR-S old |
6431207321 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) fout = open("data.txt",'w') fout.write("PYTHON is very popular \n I use LOGITEC mouse \n CHULALONGKORN is MY University") fout.close() fn = open("data.txt",'r') f = [] final = [] for line in range(3): line = fn.readline() a = line.split(" ") f.append(a) for e in f[0] : if e in ["PYTHON","LOGITEC","CHULALONGKORN" ]: final.append(e) for e in f[1] : if e in ["PYTHON","LOGITEC","CHULALONGKORN" ]: final.append(e) for e in f[2] : if e in ["PYTHON","LOGITEC","CHULALONGKORN" ]: final.append(e) fn.close() # Put your code only in this code cell. |
6431209621 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431210121 -> 0.0 -> name 'fount' is not defined |
# Adding_dashes (DO NOT modify this line) x = open("data.txt","r") z = "" for line in x : if "PYTHON" in line: x = ["PY","TH","ON"] t = "-".join(x) print(x,) fount.close() # Put your code only in this code cell. |
['PY', 'TH', 'ON'] |
6431214721 -> 0.22 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", "r") text = f.read() print(text) print() count = 0 for i in text: for j,char in enumerate(i): if count == 2 and i[j] != " ": print("-", end = '') count = 0 if char.isupper() : count = count+1 else: count = 0 print(char , end = '') |
PYTHONISTA and CPLUSplus are very POPULAR BILLBOARD TOP TP T 100 songs I use LOGITEC LOG100 LG100 L100 mouse CHULALONGKORN is MY UNVIERSITY and I am CU104 Earth is 4543000 YEARS old PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG-100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-104 Earth is 4543000 YE-AR-S old |
6431215321 -> 0.44 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin = open( "data.txt", "r" ) out = '' for line in fin : N = 0 data = line.split() for i in range(0,len(data),1) : for j in range(1,len(data[i]),1): out += data[i][j-1] if data[i][j-1] and data[i][j] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' : N += 1 if N==2 : out+= '-' N = 0 if len(data[i]) == 1 : out += data[i][0] + ' ' else : out += data[i][j] + ' ' out += '\n' fin.close() print(out) |
PY-TH-ON-IS-TA and C-PL-USplus are very P-OP-UL-AR BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY U-NV-IE-RS-IT-Y and I am CU104 Earth is 4543000 YE-AR-S old |
6431217621 -> 0.0 -> string index out of range |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. s = input() x = "" for ch in s: x += ch if ch.isupper(): if len(x) > 1: if x[-2:].isalpha(): if x[-2:].isupper(): x += "-" else: if x[-2] == "-": x = x[:-2] + x[-1] print(x) |
6431218221 -> 0.0 -> invalid syntax (<string>, line 74) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. az = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z] f = open('data.txt', 'r') for line in f: a = line.split() for k in a: b = '' t = 0 for j in k: if j not in az: break else: b += j if c%2 != 0: b += - t += 1 |
6431301621 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. from itertools import zip_longest with open("data.txt") as file: lines = file.readlines() for i, line in enumerate(lines): for string in line.split(): if string.isupper(): lines[i] = lines[i].replace(string, '-'.join(a+b for a,b in zip_longest(string[::2], string[1::2], fillvalue=""))) print("".join(lines)) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6431317721 -> 0.0 -> invalid syntax (<string>, line 66) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. data = open("data.txt","r") s = 0 for line in data: while True: if (s >= len(line)): if (s > len(line)): break elif (s == len(line)-1) print(line[s],end ="") if(line[s] != " " and line[s+1] != " ") print(line[s]+"-"+line[s+1],end = "") else: print(line[s:s+2]) s += 2 print("") |
6431319021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file = open("data.txt", "r") file.close |
6431325721 -> 0.15 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' file = open('data.txt','r') check = 0 for line in file : ans = '' for ch in line : ans += ch if check == 2: ans += '-' if ch in alpha : check += 1 else : check = 0 print(ans) |
PYT-HONISTA and CPL-USplus are very POP-ULAR BIL-LBOARD TOP- TP -T 100 songs I use LOG-ITEC LOG-100 LG1-00 L100 mouse CHU-LALONGKORN is MY -UNV-IERSITY and I am CU1-04 Earth is 4543000 YEA-RS old |
6431326321 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file0 = "data.txt" file1 = open(file0, "r") for line in file1: out = [] space_counts = [] count = 0 for c in range(len(line)): if line[c] == " ": count += 1 elif line[c] != " " and line[c-1] == " ": space_counts.append(count) count = 0 words = line.split() eline = [] for w in words: if w == w.upper(): ew = '' i = 1 for c in w: ew += c if i%2 == 0 and i < len(w): ew += "-" i += 1 eline.append(ew) else: eline.append(w) for i in range(len(space_counts)): out.append(eline[i]) out.append(" "*space_counts[i]) out.append(eline[-1]) print("".join(out)) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6431327021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431337221 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f=open('data.txt') z=[] for line in f: a=line[0] c=len(line)+2 for i in range(1,len(line)): if 'A'<=line[i-1]<='Z' and 'A'<=line[i]<='Z' and 'A'<=line[i+1]<='Z' and i!=len(line) and c!=i-1: a+=line[i]+'-' c=i else: a+=line[i] z.append(a) for x in z: print(x) |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6431339521 -> 0.0 -> name 'c' is not defined |
# Adding_dashes (DO NOT modify this line) file = open("data.txt") data=file.readline() for i in data: out='' for j in range(len(c)): if 'A'<=c[j]<='Z': n+=1 out+=c[j] if j+1<len(c): if n==2 and c[j+1]!=' ': out+='-' n=0 elif c[j+1]==' ': n=0 print(out) # Put your code only in this code cell. |
6431340021 -> 0.29 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file = open('data.txt','r') data = [] def new(c): ans = '' n = len(c) start = 0 for i in range(2,n+2,2): ans += c[start:i] + '-' start = i return ans[:-1] for line in file: data.append(line.strip()) for e in data: j = data.index(e) for c in e.split(): z = 0 if c == c.upper() and len(c) > 2: new_c = new(c) for i in range(len(e)): if c[0] == e[i]: start = i data[j] = e[:start] + new_c + e[start+len(c):] for a in data: print(a) |
PYTHONISTA and CPLUSplus are very POPO-PU-LA-R BILLBOARD TOP TP T 10-0 songs I use LOGITEC LOG100 LG100 L1-00 mouse CHULALONGKORN is MY UNVIERSITY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6431341721 -> 0.73 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for a in f: cnt = 0 out = '' for i in range(len(a)-1): out += a[i] if(not a[i].isupper()): cnt = 0 else: cnt += 1 if(cnt == 2 and a[i+1].isupper()): out += '-' if(cnt == 2): cnt = 0 print(out) |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S ol |
6431343021 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file = 'data.txt' f1 = open(file) for line in f1: line = line.strip() c = 0 o = '' for text in line: if c == 2 and 'A' <= text <= 'Z': o += '-' c = 0 if 'A' <= text <= 'Z': c += 1 else: c = 0 o += text print(o) f1.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6431350321 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431403021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431405221 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431408121 -> 0.0 -> invalid syntax (<string>, line 61) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. l = [] with open("data.txt") as file: while (line := file.readline().rstrip()): l.append(line) print(l) for i in range(len(l)): current = 0 n = 0 tmp = [i for i in l[i]] print(tmp) for j in range(len(l[i]) - 1): if current + 2 <= j+2: if l[i][j].isupper() and l[i][j+1].isupper() and l[i][j+2].isupper(): tmp.insert(j + 2 + n, "-") current = j + 2 n += 1 l[i] = "".join(tmp) for i in l: print(i) |
6431410321 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431411021 -> 0.65 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn=open("data.txt","r") for line in fn: a=line.split() b=line.upper() b=b.split() f="" for i in range(len(a)): T="" t="" if a[i]==b[i]: t+=a[i] c=0 for j in range(len(t)): T+=t[c:c+2:]+"-" c+=2 f+=T.strip("-")+" " else: f+=a[i]+" " print(f) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 10-0 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 45-43-00-0 YE-AR-S old |
6431414921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431419021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431420621 -> 0.0 -> name 'infile' is not defined |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. for line in infile: x = line.strip().split() lf = [] for e in x : sf = '' pair = [] if len(e)% 2 == 0 : for i in range(0,len(e),2) : pair.append(str(e[i:i+2])) else : for i in range(0,len(e)-1,2) : pair.append(str(e[i:i+2])) pair.append(str(e[-1])) for ch in pair : if len(ch) == 2 : if ch[0] in Alp and ch[1] in Alp : sf += ch + '-' else : sf += ch else : sf += ch if sf[-1] == '-' : sf = sf[0:-1:] lf.append(sf) sf2 = ' '.join(lf) out.append(sf2) print('\n'.join(out)) |
6431509921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fout = open("data.txt",'w') fout.write('PYTHON is very popular\n I use LOGITEC mouse\n CHULALONGKORN is MY University') fout.close() fn=open("data.txt",'r') s =[] for line in range(3) : line=fn.readline() m = line.strip().split(" ") s.append(m) for i in s : for j in range(len(i)): for l in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : if l in i[j] : i[j] = i[j][0:3]+'-'+i[j][3:len(i[j])] fn.close() |
6431513321 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431514021 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431515621 -> 0.0 -> name 'A' is not defined |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt","r") line = fin.readline() while line != '\n' : ans = '' k=1 while k < len(A) : if 'A' <= A[k] <= 'Z' and\ 'A' <= A[k-1] <= 'Z' and\ 'A' <= A[k+1] <= 'Z' : ans += str(A[k-1])+str(A[k])+'-' k +=2 else : ans += str(A[k-1])+str(A[k]) k += 2 if len(A)%2 != 0 : ans += A[-1] print (ans) line = fin.readline() fin.close() |
6431517921 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431519121 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431538021 -> 0.0 -> invalid syntax (<string>, line 65) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. infile = open(File, 'r') x=[] y=[] for line in infile: line.upper()=x.append(line) for line in infile: if x == infile(line): y = [x[0:1] '-' x[2:3]] else: y.append(x) infile.close() print(y) |
6431702621 -> 0.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. |
6431704921 -> 0.0 -> list indices must be integers or slices, not str |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", "r") t = "" s = "" for line in f: x = line.strip().split(" ") for e in x: for k in e: if "A" <= k <= "Z" and len(e) > 2: for i in range(2,len(e),2): s += e[i-2:i] + "-" if s[-1] == "-": s = s[:-1] x[e] = s s = "" print(" ".join(x)) f.close() |
6431705521 -> 0.8 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn1 = open('data.txt' , 'r') alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for line in fn1 : l = line.strip().split() ans = '' for e in l : s = 0 cap = False for i in range(len(e)) : if e[i] in alp : s += 1 if s == len(e) : cap = True if cap == True and len(e) > 2: for i in range(0,len(e),2) : if i == len(e)-1 or i == len(e)-2 : ans += e[i:i+2] else : ans += e[i:i+2] + '-' ans += ' ' else : ans += e + ' ' print(ans) fn1.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6431801021 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" a = 'abcdefghijklmnopqrstuvwxyz' for line in f: c = 0 text = '' for word in line: if c == 2 and word in A : c = 1 text += '-' + word elif word in A: c += 1 text += word elif word in a: c = 0 text += word else: c = 0 text += word print(text) f.close() |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6431806221 -> 0.29 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt", "r") def t_t(n): x = str(n)[::-1] s = "" for i in range(0, len(x), 2): s += x[i:i+2] + "-" return s[:-1][::-1] for line in fn: x = line.split() ans = [] for e in x: c = 0 for j in e: if "A" < j < "Z": c += 1 if c == len(e): c = (c+1)%2 ans += [t_t(e)] else: ans += [e] print(" ".join(ans)) fn.close() |
PYTHONISTA and CPLUSplus are very POPULAR BILLBOARD T-OP TP T 100 songs I use L-OG-IT-EC LOG100 LG100 L100 mouse CHULALONGKORN is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YEARS old |
6431810721 -> 0.68 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. file = open("data.txt") count = 0 arr = [] for line in file: for c in line: arr.append(c) for i in range(0, len(arr)): c = arr[i] print(c, end="") if c.isupper(): count += 1 if c == " ": count = 0 if count == 2 and arr[i + 1] != " ": print("-", end="") count = 0 |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R B-IL-LB-OA-RD TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG-100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-104 Earth is 4543000 YE-AR-S old |
6432015321 -> 1.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') c = [] for line in f: s = line arr = s.split() space = [] cnt = 0 for i in s: if i == ' ': cnt += 1 else: if cnt != 0: space.append(cnt) cnt = 0 chk = False for i in range(len(arr)): xx = True for aa in arr[i]: if not ('A' <= aa <= 'Z'): xx = False break if xx: new = '' cnt = 0 for j in range(0, len(arr[i]), 2): new += arr[i][j:j+2] new += '-' arr[i] = new[:-1] ans = '' idx_space = 0 for i in arr: if idx_space >= len(space): ans += i else: ans += i + (' ' * space[idx_space]) idx_space += 1 print(ans) f.close() |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6432047421 -> 1.0 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", 'r') def find_word(line): for index, char in enumerate(line): if char == ' ': return index return len(line) def count_space(line): for index, char in enumerate(line): if char != ' ': return index return 0 def add_dash(word): if len(word) % 2 == 0: char_list = [word[2*i:2*i+2] for i in range(len(word)//2)] else: char_list = [word[2*i:2*i+2] for i in range(len(word)//2 + 1)] return '-'.join(char_list) def isupper(word): for c in word: if not c.isupper(): return False return True for line in f.readlines(): line = line.strip() new_line = '' while line: index = find_word(line) word = line[:index] if isupper(word): word = add_dash(word) new_line += word new_line += ' '*count_space(line[index:]) line = line[index:].strip() print(new_line) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6432073721 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. with open("data.txt", "r") as file: a = file.read().splitlines() for line in a: temp = line.split() templine = line[:] for i in temp: if i.isupper(): tempp = "" for j in range(len(i)): if j % 2 == 0 and j != 0: tempp += "-" tempp += i[j] templine = templine.replace(i, tempp) print(templine) |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6432082321 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", "r") arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ch = 0 for i in f: for j in i: if(j in arr): ch += 1 else: ch = 0 if(ch == 3): print("-",end='') ch = 1 print(j,end='') |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6432114821 -> 0.0 -> invalid syntax (<string>, line 64) |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for line in f : for i in range(len(line)) : if line[i].isupper() f.close() |
6432117721 -> 0.8 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. out = "" with open("data.txt") as f: for line in f: res = "" for word in line.split(" "): if word.isalpha() and word.isupper(): for i, char in enumerate(word): if i % 2 == 0 and i > 0: res += "-" res += char else: res += word res += " " out += res.strip() + "\n" print(out) |
PY-TH-ON-IS-TA and CPLUSplus are very POPULAR BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LOG100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6432133721 -> 0.7 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. with open('data.txt', 'r') as f: for line in f: words = line.split(' ') for i in range(len(words)): word = words[i] if word != '': if i != 0: print(' ', end='') # word = word.strip() if word.isupper(): print('-'.join([word[i:i+2] for i in range(0, len(word), 2)]), end='') else: print(word, end='') else: print(' ', end='') |
PY-TH-ON-IS-TA and CPLUSplus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G1-00 LG-10-0 L1-00 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU-10-4 Earth is 4543000 YE-AR-S old |
6432142321 -> 0.75 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') ans = [] for line in f: start = 0 l = '' le = len(line) i = 1 while i < le: if 'A'<=line[i]<='Z' and 'A'<=line[i-1]<='Z' and 'A'<=line[i+1]<='Z': l += line[start:i+1]+'-' start = i+1 i += 2 else: i += 1 if start < le: l += line[start:] ans.append(l) for a in ans: print(a.lstrip(),end='') |
PY-TH-ON-IS-TA and CP-LU-Splus are very PO-PU-LA-R BI-LL-BO-AR-D TO-P TP T 100 songs I use LO-GI-TE-C LO-G100 LG100 L100 mouse CH-UL-AL-ON-GK-OR-N is MY UN-VI-ER-SI-TY and I am CU104 Earth is 4543000 YE-AR-S old |
6432154921 -> 0.07 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. filename = open('data.txt', 'r') # line = filename.readline() for line in filename: line = " ".join(line.split()) n = 2 lst = '' # for i in range(0, len(string)): # print(string[i:i+1]) # print([line[i:i+n] for i in range(0, len(line), n)]) for i in range(0, len(line), n): x = line[i:i+n] y = line[i:i+n].upper() if x == y: lst+='-' # print("-", end = "") # print(line[i:i+n], end = "") lst+=line[i:i+n] ans = lst[1:].replace('--', '-') print(ans) |
PY-TH-ON-IS-TA and- C-PL-USplus are very -PO-PU-LA-R BI-LL-BO-AR-D -TO-P -TP- T- 1-00 songs I use -LO-GI-TE-C -LO-G1-00- L-G1-00- L-10-0 mouse CH-UL-AL-ON-GK-OR-N is- M-Y -UN-VI-ER-SI-TY and- I am -CU-10-4 arth is- 4-54-30-00- Y-EA-RS old |
6432184721 -> 0.22 -> |
# Adding_dashes (DO NOT modify this line) # Put your code only in this code cell. Data = open("data.txt","r") In = Data.read() words = In.split() for i in range(len(words)): if words[i] == words[i].upper(): x = [] j = 0 Temp = words[i] while j<len(Temp): if j%2 == 0 and j!= 0: x.append("_") x.append(Temp[j]) j+=1 words[i]="".join(x) print(" ".join(words)) Data.close() |
PY_TH_ON_IS_TA and CPLUSplus are very PO_PU_LA_R BI_LL_BO_AR_D TO_P TP T 10_0 songs I use LO_GI_TE_C LO_G1_00 LG_10_0 L1_00 mouse CH_UL_AL_ON_GK_OR_N is MY UN_VI_ER_SI_TY and I am CU_10_4 Earth is 45_43_00_0 YE_AR_S old |
6031107321 -> 0.0 -> can only concatenate list (not "str") to list |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def toSci(num): if len(num) == 1 & int(num) == 0: return 0 else: if num[0] == "0": return num else: num = int(num) E = 0 while num/10 > 1: num /= 10 E += 1 return str(num)+"E"+str(E) infile = open("data.txt", "r") for line in infile: w = line.strip().split() out = "" for e in w: if e[0] in "0123456789": out += toSci(e) + " " else: out += w + " " print(out.strip()) infile.close() |
6130220421 -> 1.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. o = open("data.txt","r") for line in o: ls = line.strip().split(" ") ll = "" for e in ls: if e.isnumeric() and int(e[0]) != 0: if len(e) == 1: ll += str(e)+"E0"+" " elif len(e) == 2 and e[1] == "0": ll += e[0]+"E1"+" " else: ss = e[0]+"."+e[1:]+"E"+str((len(e)-1)) ll += ss+" " elif e =="": ll+= " " else: ll += e+" " print(ll.strip()) o.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 12345A234 12342212a 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6130430921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6130603121 -> 0.12 -> invalid literal for int() with base 10: '12345A234' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt",'r') for line in f: l = line.split(" ") ans = list() for i in l: if i != "" and i[0] in "123456789": if len(i) == 1: ans.append(i+"E0") elif int(i)/10 == 1: ans.append(i[0]+"E1") elif i == "0": ans.append(i) else: x = len(i)-1 ans.append(i[0]+"."+i[1:]+'E'+str(x)) else: ans.append(i) p = '' for i in ans: if p == "": p += i else: if i == "": p += " " else: p += " "+i print(p) f.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000 E9 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456 E6 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789 E9 |
6131115421 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6230155021 -> 0.0 -> 'list' object cannot be interpreted as an integer |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. #โปรแกรมที่ส่งมายังทำงานไม่สมบูรณ์ หลักการคือต้องอ่านแต่ละบรรทัดแล้วsplit()จากนั้นดูว่าเป็นตัวเลขไหม ถ้าไม่ใช่ให้บวกค่าเดิม ถ้าใช่ให้เอาตัวแรกสุดต่อด้วย','จากนั้นก็ต่อด้วยตัวที่เหลือ เติมE เติมlen(str(ตัวเลข))-1เป็นอย่างสุดท้าย #จากนั้นนำแต่ละอันกลับมาjoinด้วย' ' fin = open("data.txt","r") line = fin.readline() for line in fin : line2 = str(line)[:-1] if len(line2) == 1 : if line2 == '0' or line2 == 0 : print(line2) break else : out = str(line2) + "E0" print(out) break else : line3 = line2.split() for i in range(line3) : if line3[i] in '0123456789' : line3[i] = line3[i][0]+'.'+lin3[i][1::]+'E'+str(len(line3[i]-1)) print(' '.join(line3)) fin.close() |
6231401521 -> 0.0 -> expected an indented block (<string>, line 75) |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", "r") i = 0 x = [] y = [] for line in f: f.close() |
6231402121 -> 0.68 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def convert(x): for i in x: if not '0' < x < '9': return x if len(x) == 1: x = x+'E'+str(0) return x elif x[0] == '0': return x elif len(x) == 2 and x[1] == '0': x = x[0] + 'E' +str(1) return x else: x = x[0]+'.'+x[1:]+'E'+str(len(x[1:])) return x f = open('data.txt','r') for line in f: line = line.split() ans =[] for i in line: ans.append(convert(i)) print(' '.join(ans)) |
99523000 plus 989000 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6231407321 -> 0.74 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open('data.txt','r') num = ['0','1','2','3','4','5','6','7','8','9'] line = infile.readline() while len(line)>0: word = '' a = line.split() for k in range(len(a)): if a[k][0] in num: n = len(a[k]) if n > 1 and a[k][0] != '0': t = a[k][0] + '.' + a[k][1::] word += t + 'E'+ str(n-1) + ' ' elif n > 1 and a[k][0] == '0': word += a[k] + ' ' else: word += a[k] + 'E0' + ' ' else: word += a[k] + ' ' print(word.strip()) line = infile.readline() infile.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6231507421 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt' , 'r') for line in f : print(line) f.close() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6231515421 -> 0.43 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt') start = False for line in fin: ac = '' st = '' for x in line: if x in '0123456789': if not start: start = True ac += x elif start: start = False if ac[0] == '0': st += ac ac = '' elif len(ac) == 1: st += ac + 'E0' st += x ac = '' else: st += ac[0] + '.' + ac[1:] + 'E' + str(len(ac[1:])) st += x ac = '' else: st += x if len(ac) > 0: if ac[0] == '0': st += ac ac = '' elif len(ac) == 1: st += ac + 'E0' st += x ac = '' else: st += ac[0] + '.' + ac[1:] + 'E' + str(len(ac[1:])) st += x ac = '' print(st) fin.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 08944356181.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345E4A2.34E2 1.2342212E7a 1.234567890123456789012E21 is 1.23456789012345678901E201 |
6231516021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6231519021 -> 0.43 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open ('data.txt','r') s = False for line in f: x = '' y = '' for e in line: if e.isnumeric(): if not s: s = True x += e elif s: s = False if x[0] == '0': y += x x = '' elif len(x) == 1: y += x + 'E0' y += e x = '' else: y += x[0]+'.'+x[1:]+'E'+str(len(x[1:])) y += e x = '' else: y += e if len(x) > 0: if x[0] == '0': y += x x = '' elif len(x) == 1: y += x + 'E0' y += e x = '' else: y += x[0]+'.'+x[1:]+'E'+str(len(x[1:])) y += e x = '' print(y) f.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 08944356181.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345E4A2.34E2 1.2342212E7a 1.234567890123456789012E21 is 1.23456789012345678901E201 |
6330322521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6331508121 -> 0.37 -> name 'inflie' is not defined |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt", "r") for k in infile: x = k.split() for i in range(len(x)): if x[i].isnumeric(): if x[i][0] != '0': x[i] = str(int(x[i])/10**(len(x[i])-1)) + 'E' + str(len(x[i])-1) print(' '.join(x)) inflie.close() |
9.9523E7 plus 9.89E5 equals 1.00512E8 1.0E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.2345678901234567E18 plus 1.2345678901234567E19 12345A234 12342212a 1.2345678901234567E21 is 1.2345678901234567E20 |
6430005721 -> 0.74 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. file = open("data.txt","r") for line in file: x = line.split() for i in range(len(x)): if x[i][0] in ("123456789") and len(x[i]) != 1: x[i] = x[i][0] + "." + x[i][1:] + "E" + str(len(x[i])-1) if x[i][0] in ("123456789") and len(x[i]) == 1: x[i] = x[i] + x[i][1:] + "E" + str(len(x[i])-1) print(" ".join(x)) file.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6430010821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430011421 -> 0.0 -> invalid literal for int() with base 10: '12345A234' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f1 = open('data.txt', encoding='utf-8') out = [] for line in f1: x = [] line1 = line.strip().split(' ') for i in range(len(line1)): if line1[i] == '': x.append(line1[i]) elif '0' < line1[i][0] <= '9': p = len(line1[i])-1 if not int(line1[i]) < 10: line1[i] = line1[i][0]+'.'+line1[i][1:] if float(line1[i])%1 == 0: line1[i] = float(line1[i]) line1[i] = str(int(line1[i])) x.append(line1[i] +'E'+ str(p)) else: x.append(line1[i]) out.append(' '.join(x)) f1.close() print('\n'.join(out)) |
6430012021 -> 0.4 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt") x = [] for i in f: mum = i mum = mum.strip() x.append(mum) torb = [] for i in range(len(x)): z = x[i].split(' ') for j in range(len(z)): if(z[j].isnumeric()): if(z[j][0]!='0'): E = -1 factor = 10 omega = int(z[j]) while(omega!=0): omega = omega//10 E+=1 if(E<0): continue else: if(int(z[j])%factor**E!=0): z[j] = str(int(z[j])/factor**E)+"E"+str(E) else: z[j] = str(int(z[j])//factor**E)+"E"+str(E) torb.append(' '.join(z)) for i in torb: print(i) |
9.9523E7 plus 9.89E5 equals 1.00512E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.2345678901234567E18 plus 1.2345678901234567E19 12345A234 12342212a 1.2345678901234567E21 is 1.2345678901234567E20 |
6430020021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430022321 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430025221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430028121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430039021 -> 0.4 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. filename = 'data.txt' fn = open(filename, "r") data = [] for line in fn: line = line.strip('\n') com = line.split(' ') data.append(com) fn.close() ans = [] for i in data: temp = [] for j in i: if j.isnumeric(): number = int(j) if number == 0: temp.append(0) elif len(j) >= 1 and j[0] != '0': xxx = len(j)-1 if xxx == 0: # print(str(number)+'E0') temp.append(str(number)+'E0') else: # print(str(number/(10**xxx))+'E'+str(xxx)) temp.append(str(number/(10**xxx))+'E'+str(xxx)) else: temp.append(j) else: temp.append(j) ans.append(temp) for i in ans: for j in i: print(j,end=' ') print() |
9.9523E7 plus 9.89E5 equals 1.00512E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.2345678901234567E18 plus 1.2345678901234567E19 12345A234 12342212a 1.2345678901234567E21 is 1.2345678901234567E20 |
6430040621 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. # n = [1,2,3,4,5,6,7,8,9,0] with open('data.txt') as f: lines = f.readlines() # print(lines) nl = [] for line in lines: n = [int(s) for s in line.split() if s.isdigit() and s[0] != '0'] # print(n) nn = [] for i in range(len(n)): # p = -1 # for i in range(len(str(n[i]))): # if str(n[i])[i] != '0': # p += 1 # nn.append("{:"+p+"e}".format(n[i])) nn.append("{:1e}".format(n[i])) # print(nn) for j in range(len(n)): # print(n[j],nn[j]) nline = line.replace(str(n[j]),str(nn[j])) nl.append(nline) # print(nl) # print(nn) # for i in range(len(s)): # if s[i] in # print(lines) # print(lines[i]) # print(lines[i]) # print(lines) textfile = open("data.txt", "w") for element in nl: textfile.write(element) textfile.close() |
6430041221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430042921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt", "r") for line in fin: line = line.strip() num = "" for i in line: if i in "0123456789" and line[0] != "0" : num += i elif i == "0" and len(line) == 1: num += i if num[0] != "0" and len(num) > 1: sci = str(int(num)/(10**(len(num)-1))) + "E" + str(len(str((10**(len(num)-2))))) elif num[0] != "0" and len(num) == 1: sci = num + "E0" elif num[0] == "0" and len(num) == 1: sci = "0" elif num[0] == "0" and len(num) > 1: sci = num x = line.find(num) print(line[0:x] + sci + line[x+len(sci):]) fin.close() |
99523000 plus 989000 equals 100512009.95230009890001E22 989000 equals 100512000 1 12 123 1234 12345 123451.1212312341234512E20123456 My number is 0894435618 1234567 12345678 1234567808944356181234567123456781234567892345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 123422121.2345678901234567E54plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901.2345678901234567E4212 is 123456789012345678901 |
6430058021 -> 0.0 -> expected an indented block (<string>, line 71) |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open('data.txt', 'r') for line in infile: infile.close() |
6430060121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. with open('data.txt', 'r', encoding='utf-8') as f: while True: x = f.readline().strip() if x == '' : break # print(x) temp = x.split() target = [] for tx in temp: try: if int(tx) : x = x.replace(tx, str('%E' % (int(tx))).replace('+','')) except : continue print(x) |
9.952300E07 plus 9.890000E05 equals 1.005120E08 1.000000E00 1.000000E002 1.000000E0023 1.000000E00234 1.000000E002345 1.000000E0023456 My number is 8.944356E08 1.234567E06 1.234567E068 1.234567E0689 1.234568E18 plus 1.234568E180 12345A234 12342212a 1.234568E21 is 1.234568E20 |
6430062421 -> 0.09 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt','r') for line in fn: line.strip() info = line.split() for e in info: if '0'<=e<='9' and e[:2] != '08': if e == '0': ne = '0' else: ne = e[0]+'.'+e[1:]+'E'+str(len(e[1:])) j = info.index(e) info.remove(e) info.insert(j,ne) print(' '.join(info)) if e[:2] == '08': print(' '.join(info)) fn.close() |
99523000 plus 989000 equals 1.00512000E8 1.E0 12 123 1234 12345 123456 1.E0 1.2E1 123 1234 12345 123456 1.E0 1.2E1 1.23E2 1234 12345 123456 1.E0 1.2E1 1.23E2 1.234E3 12345 123456 1.E0 1.2E1 1.23E2 1.234E3 1.2345E4 123456 1.E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1234567 12345678 123456789 My number is 0894435618 1.234567E6 12345678 123456789 My number is 0894435618 1.234567E6 1.2345678E7 123456789 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 12345678901234567890 12345A234 12342212a 1.234567890123456789E18 plus 1.2345678901234567890E19 12345A234 12342212a 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 12342212a 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 123456789012345678901 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6430063021 -> 0.06 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fin=open("data.txt","r") for line in fin: x=line.split() for i in range(len(x)): if "0"<=x[i][0]<="9": if x[i]=="0": print(" ".join(x)) elif x[i][0]=="0": print(" ".join(x)) elif len(x[i])==1: x[i]=x[i]+"E"+"0" print(" ".join(x)) elif x[i]=='10': x[i]=x[i][0]+"E"+"1" print(" ".join(x)) else: x[i]=x[i][0]+"."+x[i][1::]+"E"+str(len(x[i])-1) print(" ".join(x)) fin.close() |
9.9523000E7 plus 989000 equals 100512000 9.9523000E7 plus 9.89000E5 equals 100512000 9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 12 123 1234 12345 123456 1E0 1.2E1 123 1234 12345 123456 1E0 1.2E1 1.23E2 1234 12345 123456 1E0 1.2E1 1.23E2 1.234E3 12345 123456 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 123456 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1234567 12345678 123456789 My number is 0894435618 1.234567E6 12345678 123456789 My number is 0894435618 1.234567E6 1.2345678E7 123456789 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 12345678901234567890 12345A234 12342212a 1.234567890123456789E18 plus 1.2345678901234567890E19 12345A234 12342212a 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 12342212a 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 123456789012345678901 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6430065321 -> 0.65 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt", "r") for line in fin : s = "" n = 0 if line[0] == "0" : print("0") else : print(line[0],end="") if "0" <= line[0] <= "9" and line[1] != "\n" : n = 1 for i in range(1,len(line)) : if i == 1 and line[i] == "0" and line[i+1] == "\n" : print("E"+str(1)) break elif i == 1 and "0" <= line[i-1] <= "9" and ("0" <= line[i] <= "9") : print("."+line[i],end="") elif "0" < line[i] <= "9" and ("a" <= line[i-1] <= "z" or "A" <= line[i-1] <= "Z" or line[i-1] == " " or line[i-1] == "\n") : print(line[i]+".",end="") n = 0 elif "0" <= line[i] <= "9" and "0" <= line[i-1] <= "9" : print(line[i],end="") n += 1 elif "0" <= line[i-1] <= "9" and ("a" <= line[i] <= "z" or "A" <= line[i] <= "Z"or line[i] == " " or line[i] == "\n") : print("E"+str(n)+line[i],end="") else : print(line[i],end="") fin.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E1 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618E9 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345E4A2.34E2 1.2342212E7a 1.234567890123456789012E21 is 1.23456789012345678901 |
6430067621 -> 0.0 -> expected an indented block (<string>, line 73) |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt", "r") outfile = open("data.txt", "w") for line in infile: x = line.strip() y = x.split() for ch in y: if 0<ch<9: infile.close() outfile.close() |
6430073321 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fin = open('data.txt','r') fout = open('output.txt.txt','w') for line in fin : x = '' num = '' for i in line : if '0'<= i <='9' : num+=i else : x+=i if num[0]=='0' : pass else : num = num[0]+'.'+num[1::]+'E'+str(len(num)-1) k=x+num fout.write(k) fin.close() fout.close() |
6430074021 -> 0.8 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt','r') lines = fn.readlines() c = [] for line in lines: x = line.split(" ") for i in range(len(x)): if x[i] == "": pass elif "1" <= x[i][0] <= "9": x[i] = x[i].strip() y = len(x[i]) if y == 1: z = "" elif x[i][1:] in "0"*100: z = "" else: z = "." + x[i][1:] x[i] = x[i][0] + z + "E" + str(y-1) x = (" ").join(x) x = x.strip("\n") print(x) fn.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6430076221 -> 0.03 -> string index out of range |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. d = open("data.txt","r") int_f = False n="" for line in d: n_line = "" int_f = False n="" for l in line: if l in "123456789": int_f=True elif int_f and l == "0": int_f=True else: int_f =False if int_f: n+=l else: print(n[0]+"."+n[1:]+"E"+str(len(n[1:]))) n_line += n[0]+"."+n[1:]+"E"+str(len(n[1:])) n="" n_line +=l print(n_line) |
9.9523000E7 |
6430084221 -> 0.0 -> substring not found |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def scientific_convertion(x): if len(x) == 1: return x + 'E0' elif int(x) % 10 == 0: return x[0] + 'E' + str(len(x) - 1) else: return str(int(x) / (10 ** (len(x) - 1))) + 'E' + str(len(x) - 1) infile = open('data.txt', 'r') digit = '' text = '' for lines in infile: for texts in lines: if texts.isdigit(): digit += texts else: text += texts if len(digit) != 0: if int(digit) == 0: print('0') else: first = lines.index(digit[0]) last = lines.rfind(digit[-1]) print(lines[0:first+1] + scientific_convertion(digit) + lines[last+1:]) else: print(text) infile.close() |
99E22 |
6430086521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430087121 -> 0.74 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def Ec(x): n = len(x[1:]) if n == 0: return x+'E0' else: h = str(x[0])+'.'+str(x[1:]) return h+'E'+str(n) e = open("data.txt",'r') for line in e: out = '' lis = line.split(' ') for i in range(len(lis)): if lis[i] == '': pass elif '9' >= lis[i][0] > '0': if lis[i][:-2:-1] == '\n': lis[i] = Ec(lis[i][0:-1])+'\n' else: lis[i] = Ec(lis[i]) print(' '.join(lis)) |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6430089421 -> 0.0 -> could not convert string to float: '99523000 plus 989000 equals 100512000' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") a = [] for line in fn: b = line[:-1] if '0' <= b[0] <='9': if b[0] == '0': a.append(b) elif len(b) == 1: a.append(b+'E0') elif b == '10': a.append('1'+'E1') elif len(b) >= 2: c = float(b)/10**(len(b)-1) d = len(b)-1 a.append(str(c)+'E'+str(d)) print('\n'.join(a)) |
6430092221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. file = open('data.txt', 'r') data = file.readlines() file.close() def Scieentific_conversion(x): E = int(x)%10 if x[0] == '0': return x else: return f"{str(int(x[::-1])/10)[::-1]}E{E}" file = open('data2.txt', 'w') for line in data: if len(line) > 1: for word in line.split(): if word.isdigit(): file.write(Scieentific_conversion(word)+' ') else: file.write(word+' ') file.write('\n') else: file.write(line+'\n') file.close() |
6430096821 -> 0.06 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fin = open("data.txt") for e in fin : if e[-1] != "\n": e += "\n" strr = "" numberr = "" number = False for q in e : if number == False : if q not in "1234567890": strr += q else : number = True numberr += q elif number == True : if q in "1234567890": numberr += q else : if numberr[0] != "0" : sci = str(format(float(numberr),"e")).split("e+") strr += sci[0] + "E" + str(int(sci[1])) else : strr += numberr strr += q number = False if strr[-1] == "\n" : print(strr[:-1]) else : print(strr) fin.close() |
9.952300E7 plus 9.952300E13 equals 9.952300E22 1.000000E0 1.120000E2 1.121230E5 1.121231E9 1.121231E14 1.121231E20 My number is 0894435618 08944356181234567 0894435618123456712345678 0894435618123456712345678123456789 1.234568E18 plus 1.234568E38 1.234568E43A1.234568E46 1.234568E54a 1.234568E21 is 1.234568E42 |
6430100621 -> 0.55 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. newlist=[] fin=open('data.txt','r') line=fin.readlines() for e in line : elist=e.split() temlist=[] for k in elist: if k.isnumeric() and k[0] != '0': leng=len(k) d=int(k) point=d/(10**(len(k)-1)) out='' out+=str(point)+'0'*(len(k)-len(str(point))+1)+'E'+str(len(k)-1) if float(out[:len(str(point))]).is_integer(): out=str(int(point))+out[len(str(point)):] temlist.append(out) else: temlist.append(k) newlist.append(temlist) for d in newlist: print(' '.join(d)) fin.close() print(newlist) |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456700E18 plus 1.2345678901234567000E19 12345A234 12342212a 1.234567890123456700000E21 is 1.23456789012345670000E20 [['9.9523000E7', 'plus', '9.89000E5', 'equals', '1.00512000E8'], ['1E0', '1.2E1', '1.23E2', '1.234E3', '1.2345E4', '1.23456E5'], ['My', 'number', 'is', '0894435618', '1.234567E6', '1.2345678E7', '1.23456789E8'], ['1.234567890123456700E18', 'plus', '1.2345678901234567000E19', '12345A234', '12342212a'], ['1.234567890123456700000E21', 'is', '1.23456789012345670000E20']] |
6430101221 -> 0.0 -> 'list' object cannot be interpreted as an integer |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. file = open('data.txt','r') a = ['1','2','3','4','5','6','7','8','9','0'] ans = [] for line in file: ll = line.strip().split() t = "" c = 0 for i in range(ll): for e in ll[i]: if e not in a: t+=ll[i] break else: num = ll[i] num = num[0]+'.'+num[1::]+'E'+str(len(num[1::])) t+=num ans.append(t) t = '' for e in ans: print(ans) |
6430109321 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430112121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430118021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430119621 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt") for line in fn.readlines(): final = "" target = "" for i in line: if "0" <= i <= "9": target += i n = len(target)-1 num = int(target) / 10**n text = str(num)+"E"+str(n) a = line.split() b =[] for i in a: if "0" <= i[0] <= "9": b.append(text) else: b.append(i) print(" ".join(b)) |
9.95230009890001E22 plus 9.95230009890001E22 equals 9.95230009890001E22 1.1212312341234512E20 1.1212312341234512E20 1.1212312341234512E20 1.1212312341234512E20 1.1212312341234512E20 1.1212312341234512E20 My number is 0.8944356181234567E33 0.8944356181234567E33 0.8944356181234567E33 0.8944356181234567E33 1.2345678901234567E54 plus 1.2345678901234567E54 1.2345678901234567E54 1.2345678901234567E54 1.2345678901234567E42 is 1.2345678901234567E42 |
6430120121 -> 0.8 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def number(x): for j in x: if j not in ['0','1','2','3','4','5','6','7','8','9']: return x if x[0]=='0': return x else: k=int(x)/10**(len(x)-1) if int(x)%10**(len(x)-1)==0: p=x[0]+'E'+str(len(x)-1) else: p=x[0]+'.'+x[1::]+'E'+str(len(x)-1) return p file=open("data.txt") k=[] for line in file: p=[] for m in line.split(): p.append(m) k.append(p) zi=[] for x in k: zi1='' for j in x: j=number(j) if len(zi1)==0: zi1+=j else: zi1+=' '+j zi.append(zi1) for i in zi: print(i) |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 12345A234 12342212a 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6430132721 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430134021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430135621 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430138521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def to_E(a) : a = str(a) ans = "" n = len(a) x = len(a)-1 if len(a) == 1 : if a == '0' : return a else : ans += a+'E'+str(x) elif len(a) == 2 : if a[1] == '0' : ans += a[0]+'E'+str(x) else : ans += a[0]+'.'+a[1:]+'E'+str(x) else : ans += a[0]+'.'+a[1:]+'E'+str(x) return ans f = open('data.txt', "r") for line in f : line = line.strip() c = -1 for i in range(len(line)) : if '0'<= line[i]<='9' : j = i c +=1 if '0'<=line[0]<= '9' : print(to_E(line)) else : print(line[0:j-c]+to_E(line[j-c:j+1])+line[j+1::]) f.close() |
9.9523000 plus 989000 equals 100512000E46 1. 12 123 1234 12345 123456E25 My number is 0894.435618 1234567 12345678 123456789E33 1.234567890123456789 plus 12345678901234567890 12345A234 12342212aE64 1.234567890123456789012 is 123456789012345678901E46 |
6430140721 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f=open('data.txt') num='0123456789' for line in f: a='';b=0;c=0 for i in line: if i in num: a+=i b+=1 if str(a[0])=='0': print(line) else: c=float(a)/(10**(len(a)-1)) if c/int(c)==1: c=int(c) a=str(c)+'E'+str(len(a)-1) else: a=str(c)+'0'*(b+1-len(str(c)))+'E'+str(len(a)-1) print(line[:line.index(a[0])]+a+line[line.index(a[0])+b:]) f.close() |
9.9523000989000110000000E22000 equals 100512000 1.12123123412345120000E2023456 My number is 0894435618 1234567 12345678 123456789 1.234567890123456700000000000000000000000000000000000000E54 12342212a 1.234567890123456700000000000000000000000000E428901 |
6430141321 -> 0.31 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt') c = 0 c_end=0 for line in fn: for i in range(len(line)) : if line[i] == '0': break if line[i] in '123456789' : c = i break for i in range(c+1,len(line)): if line[i] == ' ' or line[i] == '\n': c_end= i-1 break num = line[c:c_end+1] num_E = num[0]+'.'+num[1:]+'E'+str(len(num)-1) print(line[:c]+ num_E + line[c_end+1:]) fn.close() |
9.9523000E7 plus 989000 equals 100512000 1.E0 12 123 1234 12345 123456 M.yE1 number is 0894435618 1234567 12345678 123456789 1.234567890123456789E18 plus 12345678901234567890 12345A234 12342212a 1.234567890123456789012E21 is 123456789012345678901 |
6430142021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430145921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430148821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430153921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") line = fn.readline() while len(line) > 0 : if line.isnumeric() : print("{:e}".format(line)) line = fn.readline() else : print(line) line = fn.readline() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6430154521 -> 0.0 -> invalid literal for int() with base 10: '12345A234' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. data1 = open("data.txt","r") data2 = open("fout2.txt","w") for line in data1 : s = "" x = line.strip().split() for k in x : if "0" in k or "1" in k or "2" in k or "3" in k or "4" in k or "5" in k or "6" in k or "7" in k or "8" in k or "9" in k : if k[0:2] == "08" : s += k +" " else : y = str(int(k) / (10**(len(k)-1)))+"E"+str(len(k)-1)+ " " s += y + " " else : s += k+" " data2.write(s+"\n") data1.close() data2.close() |
6430156821 -> 0.0 -> name 'f' is not defined |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. for line in f: x = line.strip().split() for i in range(len(x)): if x[i][0] != "0" and x[i].isnumeric(): n = int(x[i])//10 # if n != 0: new = int(x[i])%1 x[i] = str(n)+"."+str(new)+"E"+str(n) print(" ".join(x)) f.close() |
6430157421 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6430195221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431001321 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431003621 -> 0.0 -> expected an indented block (<string>, line 69) |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def demo_readline(): f = open("data.txt") data = f.readline() for data in f : print('0') data2 = f.readline() for data2 in f : prirnt(data2) f.close() |
6431013921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431015121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431016821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431022521 -> 0.74 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. file=open('data.txt') for line in file: line = line.strip().split() result=[] for i in line: if i[0] in '123456789' and len(i)>1: x=i[0] y=i[1:] z=len(y) if len(y)==1 and y=='0': result.append(x+'E'+'1') else: result.append(x+'.'+y+'E'+str(z)) elif i[0] in '123456789' and len(i)==1: result.append(i+'E'+'0') else: result.append(i) print(' '.join(result)) file.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6431023121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") kormoon = "" for line in fn : kormoon += line fn.close() fout = open("data.txt","w") fout.write(kormoon) fout.close() |
6431029021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431107221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. read_file = open('data.txt' ,'r+') while True: s = read_file.readline() if s == '': break; s2 = s.strip('\n') a="" for e in range(len(s2)): if s2[e] in '0123456789': a+=s2[e] if a[-1]!=0 and len(a)!=1: k = a[0]+'.'+a[1:-1]+'E'+str(len(a)-1) if int(a)%(10**(len(a)-1))==0: k = a[0]+'E'+str(len(a)-1) if a[0]=='0': print(s2) elif a=='': print(s2) else: b = s2.find(a[0]) vv = s2[0:b]+k+s2[b+len(a):-1] print(vv) read_file.close() |
9.952300098900010051200E22000 equals 10051200 1.1212312341234512345E202345 My number is 0894435618 1234567 12345678 123456789 1.23456789012345678912345678901234567890123452341234221E54 12342212 1.23456789012345678901212345678901234567890E42890 |
6431113021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431117521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431125521 -> 0.37 -> invalid literal for int() with base 10: '12345A234' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. t = open("data.txt") for l in t: l = l.strip().split() for j in range(len(l)): for i in range(10): if str(i) in l[j]: c = len(l[j]) l[j] = int(l[j])/10**(c-1) l[j] = str(l[j])+'E'+str(c-1) break text = '' for i in l: if i != '0.0E0': text += i + ' ' else: text += '0' print(text) |
9.9523E7 plus 9.89E5 equals 1.00512E8 1.0E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0.894435618E9 1.234567E6 1.2345678E7 1.23456789E8 |
6431133521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. data = open("data.txt", "r") line = data.readline() n = "" nn = [] for e in line: newnum = "" for i in e: if str(i) in ["0","1","2","3","4","5","6","7","8","9"]: n += str(i) for j in n[1::]: newnum = str(n[0]) + "." + str(j) if len(n) > 1: newnum += "E" + str(len(j)-1) elif len(n) == 1: newnum += "E" + "0" nn.append(newnum) for e in line: for i in range(len(e)): if str(e[i]) in ["0","1","2","3","4","5","6","7","8","9"]: print("") elif str(e[i]) in ["0","1","2","3","4","5","6","7","8","9"] and i+1 >= len(e): print(newnum[e]) elif str(e[i]) in ["0","1","2","3","4","5","6","7","8","9"] and str(e[i+1]) not in ["0","1","2","3","4","5","6","7","8","9"]: print(newnum[e]) else: print(e[i]) |
p l u s e q u a l s |
6431135821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431137021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431141521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431145021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431148021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. import string def firstDigit(n) : while n >= 10: n = n / 10; return int(n) class MyFormatter(string.Formatter): def format_field(self, value, format_spec): if format_spec == 'm': return super().format_field(value, 'e').replace('e+', 'e') else: return super().format_field(value, format_spec) fmt = MyFormatter() f = open("data.txt", "r") data = (f.read()).split("\n") for elem in data: res = [int(i) for i in elem.split() if i.isdigit()] # print(firstDigit(res[0])) if firstDigit(res[0]) != 0: temp_str = elem.replace(str(res[0]), str(fmt.format('{:m}', int(res[0]))) ) else: temp_str = elem print(temp_str) |
9.952300e07 plus 989000 equals 100512000 1.000000e00 1.000000e002 1.000000e0023 1.000000e00234 1.000000e002345 1.000000e0023456 My number is 08.944356e08 1234567 12345678 123456789 1.234568e18 plus 1.234568e180 12345A234 12342212a 1.234568e21 is 123456789012345678901 |
6431150121 -> 0.0 -> invalid literal for int() with base 10: '' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') code = [e.strip().split('/n') for e in f.readlines()] f.close() def change(code) : re = [] for word in code : for e in word : ans = '' if '0' <= e <='9' : ans += e if int(ans) == 0 : re.append(ans) elif len(ans) == 1 : re.append(ans+('E0')) elif len(ans) > 1 : a = int(ans)/10 b = len(ans)-1 re.append(str(a)+'E'+str(b)) return re print(change(code)) |
6431203821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f1 = open('data.txt') a = [] for line in f1: if line.strip().isnumeric() : a.append(int(line.strip())) else: a.append(line.strip()) f1.close() for e in a: if str(e).isnumeric(): if e == 0: print(0) elif len(str(e)) == 1: print(str(e)+'E0') else: x = str(e) print(x[0]+'.'+x[1:]+'E'+str(len(x)-1)) else: print(e.strip()) |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6431204421 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431208021 -> 0.06 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for line in f: b= '' a='' for i in line : if i=='\n' : continue else : b += str(i) for i in line: if i=='\n' : continue if '0'<=str(i)<='9' : a+=str(i) aindex = line.index(a[0]) else : a = '' pass if len(a)==1 : print('-') else : ans = '' if len(a)!=0: if a[0]=='0' : print(b) elif a[1] != 0: need = int(a)/(len(a)-1) show = (len(a)-1) ans+= str(a[0]+'.'+a[1:]+'E'+str(show)) Ans = str(b[:aindex]+ans+b[aindex+len(a)+1:]) if len(a)==2 and Ans[-3]=='0': ans+= str(a[0]+'E'+str(show)) Ans = str(b[:aindex]+ans+b[aindex+len(a)+1:]) print(Ans) else : print(Ans) elif a[1] == 0: need = int(a)/(len(a)-1) show = (len(a)-1) ans+= str(a[0]+'.'+'E'+str(show)) Ans = str(b[:aindex]+ans+b[aindex+len(a)+1:]) print(Ans) f.close() |
99523000 plus 989000 equals 1.00512000E8 1.23456E53 1234 12345 123456 My number is 089443561.23456789E8 12345678 123456789 1.23456789012345678901E20 is 123456789012345678901 |
6431220421 -> 0.0 -> expected an indented block (<string>, line 86) |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. a = open("data.txt") for line in a: |
6431223321 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431229121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431230721 -> 0.0 -> name 'name' is not defined |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. if name == "main": f = open('data.txt', 'r') s = f.read() f.close() data = s.split('\n') print(data) for i in range (5): s = '' ele = int(data[i]) |
6431234221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431302221 -> 0.0 -> name 'output_line' is not defined |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt", "r") for x in infile: for idx, i in enumerate(x): cnt = 0 if i <= '9' and i >= '0': cnt += 1 else: if cnt >= 1: output_line = x[:idx-cnt] + '.' + x[idx-cnt:idx] + 'E' + cnt + x[idx:] else: cnt = 0 print(output_line) infile.close() |
6431304521 -> 0.0 -> could not convert string to float: '1.2345A234' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def change_to_science(N): length = len(str(N)) N = N.strip() if str(N)[0] == "0": return N else: if len(N) == 1 or float((str(N)[0]+"."+str(N)[1:])).is_integer(): front = str(N)[0]+"."+str(N)[1:] end = N.find(".") if end == -1: front = N[0:] else: front = N[0:end] divided = front+"E"+str(length-1) else: divided = str(N)[0]+"."+str(N)[1:]+"E"+str(length-1) return divided fin = open("data.txt","r") ans = [""] for line in fin: line = line.strip() start = -1 end = -1 i = 0 while i < len(line): if line[i] in "0123456789": start = i end = line.find(" ",i+1) if end == -1: num = line[start:] i+= len(line) else: num = line[start:end] num_science = change_to_science(num) ans[-1] += num_science i += abs(end-start-1) else: ans[-1] += line[i] i+=1 ans.append("") print(*ans,sep="\n") |
6431306821 -> 0.0 -> could not convert string to float: '99523000 plus 989000 equals 100512000' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. filename = "data.txt" infile = open(filename, "r") outp = infile.readlines() for e in outp: if e[-1] == "\n": outp[outp.index(e)] = e[:-1] infile.close() for e in outp: if "1" <= e[0] <= "9": if float(e) / 10 ** (len(e) - 1) - round(float(e) / 10 ** (len(e) - 1)) == 0.0: outp[outp.index(e)] = ( str(round(float(e) / 10 ** (len(e) - 1))) + "E" + str(len(e) - 1) ) else: outp[outp.index(e)] = ( str(float(e) / 10 ** (len(e) - 1)) + "E" + str(len(e) - 1) ) for e in outp: print(e) |
6431318321 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') def isnum(x): try: a = int(x) except (TypeError, ValueError): return False else: return True for line in f: line=line.split(' ') for word in range(len(line)): if isnum(line[word]): if line[word]=='0': pass else: n=len(line[word]) line[word]=str(int(line[word])/(10**(n)))+'0'*(n-len(str(int(line[word])/(10**(n)))))+'E'+str(n-1) print(' '.join(line)) f.close() |
0.995230E7 plus 0.9890E5 equals 0.01005120E9 0.1E0 0.12E1 0.123E2 0.1234E3 0.12345E4 0.0123456E6 My number is 0.0894435618E9 0.1234567E6 0.12345678E7 0.0123456789E9 0.12345678901234568E18 plus 0.123456789012345680E19 12345A234 12342212a 0.12345678901234568000E21 is 0.1234567890123456800E20 |
6431320521 -> 0.0 -> slice indices must be integers or None or have an __index__ method |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open('data.txt','r') for k in infile: k = k.strip() st = '' s = k.split() i = 0 while i <= len(k): if k[i] not in '123456789': st += k[i] i += 1 if k[i] == 0: for j in k[i::]: if j not in '0123456789': c = j break n = len(k[i:c]) i += n else: c = 0 for j in k[i+1::]: if j not in '0123456789': c = j break n = len(k[i:c]) e = int(k[i:c]) x = str(int(e)/(10*(n-1))) x += 'E' + str(len(n)-1) i += n st += x print(st) |
6431321121 -> 0.0 -> invalid literal for int() with base 10: '99523000 plus 989000 equals 100512000\n' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. file = open('data.txt') ans = '' for line in file: if int(line): ans += str(line[0]) if (int(line[0:2])/10) > 1: ans += '.'+line[1:-1] ans += 'E'+str(len(line[2:])) else: ans += '0' print(ans) ans = '' file.close() |
6431322821 -> 0.0 -> name 'lines' is not defined |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. lines = [lines.strip() for line in open("data.txt")] for item in lines: k = item.split() for e in k: s = "" if e[0] == "0": e = e elif e[0] in "123456789": digit = len(e) - 1 s = e[0] + "." + e[1:] + "E" + str(digit) e = s x = " ".join(k) print(x) |
6431324021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. import math f = open("data.txt") li = [] for line in f: ff = False words = line.split() for i in range(len(words)): if 'a'<= words[i][0].lower() <= 'z' or words[i][0] == '0': pass else: try: num = float(words[i]) ff = True e = math.log(num,10)//1 num = num/(10**e) ind = line.find(words[i]) new = str(num)+'E'+str(e) words[i] = new except: pass li.append(" ".join(words)) """if ff == True: li.append(line[:ind]+str(num)+'E'+str(e)+line[ind+len(words[i]):]) else: li.append(line)""" for k in li: print(k) |
9.9523E7.0 plus 989000 equals 100512000 9.9523E7.0 plus 989000 equals 100512000 9.9523E7.0 plus 9.89E5.0 equals 100512000 9.9523E7.0 plus 9.89E5.0 equals 100512000 9.9523E7.0 plus 9.89E5.0 equals 1.00512E8.0 1.0E0.0 12 123 1234 12345 123456 1.0E0.0 1.2E1.0 123 1234 12345 123456 1.0E0.0 1.2E1.0 1.23E2.0 1234 12345 123456 1.0E0.0 1.2E1.0 1.23E2.0 1.234E3.0 12345 123456 1.0E0.0 1.2E1.0 1.23E2.0 1.234E3.0 1.2345E4.0 123456 1.0E0.0 1.2E1.0 1.23E2.0 1.234E3.0 1.2345E4.0 1.23456E5.0 My number is 0894435618 1234567 12345678 123456789 My number is 0894435618 1234567 12345678 123456789 My number is 0894435618 1234567 12345678 123456789 My number is 0894435618 1234567 12345678 123456789 My number is 0894435618 1.234567E6.0 12345678 123456789 My number is 0894435618 1.234567E6.0 1.2345678E7.0 123456789 My number is 0894435618 1.234567E6.0 1.2345678E7.0 1.23456789E8.0 1.2345678901234567E18.0 plus 12345678901234567890 12345A234 12342212a 1.2345678901234567E18.0 plus 12345678901234567890 12345A234 12342212a 1.2345678901234567E18.0 plus 1.2345678901234567E19.0 12345A234 12342212a 1.2345678901234567E18.0 plus 1.2345678901234567E19.0 12345A234 12342212a 1.2345678901234567E18.0 plus 1.2345678901234567E19.0 12345A234 12342212a 1.2345678901234567E21.0 is 123456789012345678901 1.2345678901234567E21.0 is 123456789012345678901 1.2345678901234567E21.0 is 1.234567890123457E20.0 |
6431328621 -> 0.71 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. filename = open('data.txt', 'r') res = [] for line in filename: words = line.split() lineres = [] if len(words) > 1: for i in words: if '1' <= i[0] <= '9': num = i a = num[0] + '.' + num[1:] z = len(i) - 1 lineres.append(str(a) + 'E' + str(z)) else: lineres.append(i) res.append(' '.join(lineres)) else: res.append('-') for i in res: print(i) |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1.E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6431330821 -> 0.0 -> can only concatenate str (not "int") to str |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') def checker(N): a=N[0] b=N[1:] if '123456789' not in b: ans=a+'E'+len(b) return ans else: ans=a+'.'+b+'E'+len(b) return ans line=f.readline() while line!='': line.split() if len(line)==1: if line[0]=='0': print('0') elif len(line[0])==1 and line[0]!='0': print(line[0]+'E0') else: print(checker(line[0])) else: for i in line: if i[0]=='0': print(' '.join(line)) break else: if i in '1234567890': i=checker(i) print(' '.join(line)) line=f.readline() f.close() |
6431331421 -> 0.55 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. with open('data.txt', 'r') as f: data = f.readlines() for line in data: items = line.strip('\n').split(' ') for i, item in enumerate(items): if item.isnumeric(): len_item = len(item) if item[0] == '0': print(item,end='') else: print(item[0], end='') if len(item) > 1: if item[1] == '0' and item[-1] == '0': pass elif item[1] == '0' and item[-1] != '0': print('.{}'.format(item[1:])) elif item[-1] == '0': end_point = len(items)-1 for j, digit in enumerate(item[-2::-1]): if digit != 0: end_point -= j break print('.{}'.format(item[1:end_point]), end='') else: print('.{}'.format(item[1:]), end='') print("E{}".format(len_item-1), end=' ') else: print(item, end='') if i == len(items)-1: print('\n', end='') else: print(' ', end='') |
9.9523000E7 plus 9.89000E5 equals 1E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.234E19 12345A234 12342212a 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6431332021 -> 0.0 -> name 'Decimal' is not defined |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fl = open("data.txt","r") for line in fl : data = line.split() for i in range(len(data)) : if data[i][0] == '0' and '0'<= data[i][0] <= '9' : data[i] = str('%E' % Decimal(data[i])) print(" ".join(data)) fl.close() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 |
6431334321 -> 0.31 -> could not convert string to float: '12345A234' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. import string f = open('data.txt') for line in f: i = 0 line = line.replace('\n','') words = line.split() for word in words: if word == '': pass else: k = word.strip() if k[0] not in string.digits or k[0] == '0': pass else: num = float(k) n = len(k)-1 m = num / (10**(n)) if m % 1== 0: m = int(m) elif len(str(m)) != len(k) + 1: m = str(m) + '0'*(len(k)-len(str(m))+1) ans = str(m)+'E'+str(int(n)) line = line.replace(word,ans) print(line) |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1E02 1E023 1E0234 1E02345 1E023456 My number is 0894435618 1.234567E6 1.234567E68 1.234567E689 |
6431338921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt", "r") n = [] while True: c = [] t = f.readline() if len(t) == 0: break x = t.strip().split() for i in x: if i.isnumeric(): i = int(i) c.append(format(i,"E")) else: c.append(i) n.append(c) for i in n: print(" ".join(i)) f.close() |
9.952300E+07 plus 9.890000E+05 equals 1.005120E+08 1.000000E+00 1.200000E+01 1.230000E+02 1.234000E+03 1.234500E+04 1.234560E+05 My number is 8.944356E+08 1.234567E+06 1.234568E+07 1.234568E+08 1.234568E+18 plus 1.234568E+19 12345A234 12342212a 1.234568E+21 is 1.234568E+20 |
6431342321 -> 0.0 -> list index out of range |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. ## ไม่เสร็จ ## fn = open('data.txt','r') all_line = [] all_numbers = [] all_numbers_sci = [] bin = [] for line in fn: all_line.append(line) x = line.split() numbers = [] for item in x: try: if len(int(item)) == len(str(item)): numbers.append(int(item)) except: pass numbers_sci = [] for number in numbers: e = len(str(number))-1 out_front = number/(10**e) out_front = str(out_front) if len(str(out_front)) < len(str(number)): out_front += '0'*(len(str(number))-len(str(out_front))+1) elif len(str(out_front))-1 > len(str(number)): out_front = str(number)[0] if out_front == '0' or out_front == '1': numbers_sci.append(str(out_front)) numbers_sci.append(str(out_front)+'E'+str(e)) #Qprint(numbers) #print(numbers_sci) all_numbers.append(numbers[0]) all_numbers_sci.append(numbers_sci[0]) #print(all_numbers) #print('sci',all_numbers_sci) fn.close() |
6431345221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. num = '1234567890' ans = [] infile = open('data.txt','r') for line in infile: x = line.strip() ind = [] for i in range(len(x)): if x[i] in num: ind.append(i) print(ind) if len(x)!=1 and x[ind[0]]!='0': newx = x[:ind[0]]+x[ind[0]]+'.'+x[ind[1]:ind[-1]+1]+'E'+str(len(ind)-1)+x[ind[-1]+1:] ans.append(newx) elif x=='0': ans.append(x) elif len(x)==1 and x in num: newx = x+'E0' ans.append(newx) infile.close() for e in ans: print(e) |
[0, 1, 2, 3, 4, 5, 6, 7, 20, 21, 22, 23, 24, 25, 38, 39, 40, 41, 42, 43, 44, 45, 46] [0, 2, 3, 5, 6, 7, 9, 10, 11, 12, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25] [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46] 9.9523000 plus 989000 equals 100512000E22 1.12 123 1234 12345 123456E20 1.234567890123456789 plus 12345678901234567890 12345A234 12342212E54a 1.234567890123456789012 is 123456789012345678901E42 |
6431346921 -> 0.8 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def sci(n): if n == '0': return '0' elif n[0] == '0': return n elif int(n) > 10: return n[0] + '.' + n[1:] +'E'+str(len(n)-1) else: return n[0] +'E'+str(len(n)-1) f = open('data.txt') l = [] for line in f: x = line.split() if len(x) == 1 and x[0].isdigit(): l.append(sci(x[0])) elif len(x) >=1: tmp = [] for w in range(len(x)): if x[w].isdigit(): tmp.append(sci(x[w])) else: tmp.append(x[w]) l.append(" ".join(tmp)) else: l.append(x) for d in l: print(d) f.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 12345A234 12342212a 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6431348121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f=open('data.txt','r') str='' for line in f.readline(): if line[:-1].isdigit(): line=line.strip() c=len(line) line=int(line) s=line//10 t=line/10**c str+=str(t)+'E'+str(c)+'/n' else: str+=line print(str) f.close() |
99523000 plus 989000 equals 100512000 |
6431349821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt', 'r') num_list = [] new_num = [] text = '' for line in fn: text += line num_list += [i for i in line.split() if i.isdigit()] for num in num_list: if num[0] != '0': if len(num) == 1: ans = num + 'E0' new_num.append(ans) else: ans = str(int(num) / (10**(len(num)-1))) + 'E' + str(len(num)-1) new_num.append(ans) else: new_num.append(num) # print(num_list) # print(new_num) z = 0 for i in text.split(): if i.isdigit(): text.replace(i,new_num[z]) z += 1 print(text) fn.close() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6431407521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431409821 -> 0.0 -> expected an indented block (<string>, line 85) |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt") for line in f: if len(line.strip()) == 1: |
6431415521 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') for line in f: a = line.split() k = [] for e in a: if e[0] in "0123456789": if "number" in a: k.append(e) break if len(e) == 1: n = e[0] + "E0" elif e[1] == "0" and len(e) == 2: n = e[0] + "E" + str(len(e)-1) else: n = e[0] + "." + e[1:] + "E" + str(len(e)-1) k.append(n) else: k.append(e) f.close() print(" ".join(k)) |
1.234567890123456789012E21 is 1.23456789012345678901E20 |
6431501821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431504721 -> 0.0 -> [Errno 2] No such file or directory: 'final.py' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('final.py') for line in f: scientific_notation = "{:e}".format(line) f.close() print(scientific_notation) |
6431510421 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431518521 -> 0.6 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. with open('data.txt') as fp : data = fp.readlines() data = [data[i].strip().split(' ') for i in range(len(data))] for i in data : for j in range(len(i)) : if i[j].isnumeric() : if i[j][0] == '0': pass else : e = len(i[j])-1 x = float(i[j])/(10**e) if float(i[j])%(10**e) == 0 : x = int(x) else : while len(str(x)) <= len(i[j]) : x = str(x)+'0' i[j] = str(x) + 'E' + str(e) for i in data : for j in i : print(j,end=' ') print() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456700E18 plus 1.2345678901234567000E19 12345A234 12342212a 1.234567890123456700000E21 is 1.23456789012345700000E20 |
6431525921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open('data.txt','r') |
6431529421 -> 0.0 -> string index out of range |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open("data.txt") for line in f: words = line.strip().split(" ") ans = " " for word in words: check = 1 for letter in word: if letter not in "1234567890": check = 0 break if len(word) == 0 or word[0] == "0": check = 0 if len(word) == 1: ans += word + "E0" else: ans += word[0] + "." + word[1:] + "E" + str(len(word)-1) + " " else : ans += word + " " |
6431530021 -> 0.0 -> invalid literal for int() with base 10: '1 12 123 1234 12345 123456\n' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt","r") line = infile.readline() for line in infile: if int(line) % 10 == 0: print(line) else: if int(line) % 10 <= 1: print(line+'E0') infile.close() |
6431531621 -> 0.0 -> 'in <string>' requires string as left operand, not list |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. d = open("data.txt","r") line = d.readline() k = '' num = '0123456789' for line in d : for i in line.split() : if sorted(i) in num : k += str(int(i)%(10**len(str(i)))) + 'E' + str(len(str(i))) else : k += i print(k) k = '' d.close() ## เปิดแฟ้มไม่ได้ |
6431532221 -> 0.0 -> [<class 'decimal.ConversionSyntax'>] |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. from decimal import Decimal lines = [] with open('data.txt') as f: lines = f.readlines() for line in lines: a = '%E' % Decimal(line) print(a.split('E')[0].rstrip('0').rstrip('.') + 'E') |
6431537421 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fn = open("data.txt","r") for line in fn: x = '' if line[0] in '1234567890': if line == '0\n': x += '0' elif len(line)==2: x += line[0] + 'E0' elif len(line)>2: x += line[0] + '.' + line[1:-1] + 'E' +str(len(line)-2) else: z = '' y = '' for i in range(len(line)): if line[i] in '1234567890': y += line[i] c = i if len(y)==2: z += y[0] + 'E0' elif len(line)>2: z += y[0] + '.' + y[1:-1] + 'E' +str(len(y)-1) if y[0] != '0': x += line[0:line.find(y[0])] + z +line[c+1:-1] else: x = line print(x) fn.close() |
9.9523000 plus 989000 equals 100512000E46 1. 12 123 1234 12345 123456E25 My number is 0894435618 1234567 12345678 123456789 1.234567890123456789 plus 12345678901234567890 12345A234 12342212aE64 1.234567890123456789012 is 12345678901234567890E45 |
6431539721 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431540221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431546021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt', 'r') for a in f.readlines(): a = a.strip().split() for i in range(len(a)): try: if a[i][0] != '0': r = f"{Decimal(a[i]):E}" if r.find('+') != -1: r = r[:r.find('+')] + r[r.find('+')+1:] a[i] = r except: continue print(" ".join(a)) f.close() |
99523000 plus 989000 equals 100512000 1 12 123 1234 12345 123456 My number is 0894435618 1234567 12345678 123456789 1234567890123456789 plus 12345678901234567890 12345A234 12342212a 1234567890123456789012 is 123456789012345678901 |
6431547721 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431548321 -> 0.0 -> invalid syntax (<string>, line 69) |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. fo = open("data.txt","r") result = [] i = 0 for x in fo: if x[] isinstance(int): result.append("-") else: for j in i: if j isinstance(int): result.append(i/len(i*10)+"E") else: result.append(j) i += 1 print(result) |
6431703221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. infile = open("data.txt","r") a=[] for line in infile: a.append(line) infile.close() |
6431804021 -> 0.0 -> could not convert string to float: 'data.txt' |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. x=float(input()) scientific_notation = "{:.2E}".format(x) print(scientific_notation) |
6431807921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6431809121 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6432026221 -> 0.8 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def intToSci(s): if s == '0' or s[0] == '0': return s result = s[:1] if len(s[1:]) > 0 and s[1:] != '0': result += '.' + s[1:] result += 'E' + str(len(s) - 1) return result with open("data.txt") as fp: for line in fp: lineStrip = line.strip() result = '' idx_s = -1 for i in range(len(lineStrip)): if lineStrip[i].isdigit() and idx_s == -1: idx_s = i elif not lineStrip[i].isdigit() and idx_s != -1: result += intToSci(lineStrip[idx_s : i]) idx_s = -1 if not lineStrip[i].isdigit(): result += lineStrip[i] if idx_s != -1: result += intToSci(lineStrip[idx_s:]) print(result) |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345E4A2.34E2 1.2342212E7a 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6432051921 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') f.close() |
6432055421 -> 0.8 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. with open("data.txt",'r') as file: n = file.readlines() for i in range(len(n)): ans = "" a = n[i].split() for j in a: if(j.isdigit()): if(len(j) > 1 and j[0] == "0"): ans += j + " " elif(len(j)==1): ans += j if(j != "0"): ans += "E0" ans += " " else: ans += j[0] + "." + j[1:] + "E" + str(len(j)-1) + " " else: ans += j + " " print(ans[:-1]) |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 12345A234 12342212a 1.234567890123456789012E21 is 1.23456789012345678901E20 |
6432064021 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. def inten(x): n = len(x) y = int(x) if len(x) == 1 and x != '0': a = x[0] + 'E'+str(len(x[1::])) return a elif x[0] == '1' and int(x[1:]) == 0: a = x[0] + 'E'+str(len(x[1::])) return a elif x[0] != '0': a = x[0] + '.' +x[1::] + 'E'+str(len(x[1::])) return a return x fin = open( 'data.txt', 'r') for line in fin: num = '' found = False foundstop = False for c in line: if c in '0123456789': num += c if found == False: start = line.find(c) found = True if num == inten(num): print(line.strip()) else: print((line[0:start]+inten(num)+line[start+len(num):]).strip()) |
9.9523000989000100512000E22000 equals 100512000 1.12123123412345123456E2023456 My number is 0894435618 1234567 12345678 123456789 1.234567890123456789123456789012345678901234523412342212E54 12342212a 1.234567890123456789012123456789012345678901E428901 |
6432085221 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6432169321 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. |
6432172121 -> 0.4 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt') def change(x): newx = x newx = newx.strip('\n') list = newx.split() for i in range(len(list)): if list[i].startswith('0'): continue try: a = int(list[i]) count = 0 anew = a while anew >= 10: anew = anew/10 count += 1 u = a/(10**count) if int(u) == u: u = int(u) list[i] = str(u)+'E'+str(count) except: pass return ' '.join(list) file = f.readlines() f.close() for fi in file: print((change(fi))) |
9.9523E7 plus 9.89E5 equals 1.00512E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.2345678901234567E18 plus 1.2345678901234567E19 12345A234 12342212a 1.2345678901234567E21 is 1.2345678901234567E20 |
6432173821 -> 0.0 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. ff = open("data.txt", "r").read().split("\n") for i in range(len(ff)) : c = ff[i].split(" ") for j in range(len(c)) : try : n = float(c[j]) if(c[j][0]=='0') : continue c[j]=format(n, "E").replace("+","") except : 1 c.append("1") for k in range(len(c)-1) : if(c[k]=="") : print(" ",end="") else : print(c[k],end="") if(c[k]!="") : print(" ",end="") print() |
9.952300E07 plus 9.890000E05 equals 1.005120E08 1.000000E00 1.200000E01 1.230000E02 1.234000E03 1.234500E04 1.234560E05 My number is 0894435618 1.234567E06 1.234568E07 1.234568E08 1.234568E18 plus 1.234568E19 12345A234 12342212a 1.234568E21 is 1.234568E20 |
6432187621 -> 0.8 -> |
# Scientific_conversion (DO NOT modify this line) # Put your code only in this code cell. f = open('data.txt','r') for line in f: s = line.strip().split() aa = [] for i in s: if i[0] in '123456789': z = '' z+=i[0] if len(i) > 1: if '1' in i[1:] or '2' in i[1:] or '3' in i[1:] or '4' in i[1:] or '5' in i[1:] or '6' in i[1:] or '7' in i[1:] or '8' in i[1:] or '9' in i[1:]: z+='.'+i[1:] z+='E'+str(len(i)-1) aa.append(z) else: aa.append(i) #print(aa) chk = True cnt = 0 for i in line: if i == ' ' or i == '\n': print(i,end='') chk=True elif chk: print(aa[cnt],end='') cnt+=1 chk=False else : pass f.close() |
9.9523000E7 plus 9.89000E5 equals 1.00512000E8 1E0 1.2E1 1.23E2 1.234E3 1.2345E4 1.23456E5 My number is 0894435618 1.234567E6 1.2345678E7 1.23456789E8 1.234567890123456789E18 plus 1.2345678901234567890E19 1.2345A234E8 1.2342212aE8 1.234567890123456789012E21 is 1.23456789012345678901E20 |