0
How do I integrate these two codes?
Code 1 https://code.sololearn.com/cENSWI6Pz81P/#py Code 2 https://code.sololearn.com/c11fB445tINj/#py The goal is to provide alphabetical input, have it converted to numbers, then have the words count off starting at 1 (I might change this later) I am open to other ways to get the same results
7 odpowiedzi
+ 2
Steven the answer is right in your question. There is a parameter called “sep” in print(). Its a separator.
print(ord(s[x])-65-6*s[x].islower() if s[x].isalpha() else "(unknown yet)",str(y),sep=", ")
+ 4
Can you please make a sample of input with a real text? I i use your code with input "hello" it gives this output:
h3
e3
l3
l3
o3
It is also not claer what you want to achieve in general. Is it a kind of cypher?
+ 2
im pretty sure you cant do that on sololearn. I have provided a solution. replace line 6 in code #1 with the following
print(ord(s[x])-65-6*s[x].islower() if s[x].isalpha() else "UNKNOWN",str(y))
+ 1
the sample input is in “input code” on the last line as a note. the output of the combined codes will be the input of a code that will pull info from Individual cells of a spreadsheet
+ 1
import string
the_alphbet = string.ascii_uppercase + string.ascii_lowercase
mylist = dict(zip(the_alphbet, (x for x in range(len(the_alphbet)))))
mystring = "This is a test"
myint = 1
for x in mystring:
if x == ' ':
myint += 1
print(mylist.get(x), myint)
+ 1
@Choe is it possible to have the numbers separated by a ", " (,[space])?
0
input(This is a test)
Code 1 current output:
T1
h1
i1
s1
1
i2
s2
2
a3
3
t4
e4
s4
t4
Desired output:
19, 1
33, 1
34, 1
44, 1
1 (unknown yet)
34, 2
44, 2
2 (unknown yet)
26, 3
3 (unknown yet)
45, 4
30, 4
44, 4
45, 4