Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
For example:
input: "Orange"
output: "O0r1a2n3g4e5"
I know I will have to convert the string to a list so I can iterate and append the index numbers, but I don't know how to do that in code.
''.join([f'{letter}{index}' for index, letter in enumerate(input)])
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 days ago.
Improve this question
for example I have a string of
001100
010010
010010
001100
the shape of the 1's is the number zero
all I need to do is to get how many zero's there are in the string
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
For example, "1234" and I want the program knows that 1 is the smallest value. Thank you
This may be of help.
x = min('1234')
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
If two list is having same number, then the final list should not have the number
If your lists contains unique elements, consider using sets instead.
https://docs.python.org/2/library/sets.html
Check this code:
ls=[1,2,3,4,5,5]
ls1=[1,2,3,4,5,7,8,9]
common_elements=set(ls).intersection(set(ls1))
for i in common_elements:
if ls.__contains__(i):
ls.remove(i)
if ls1.__contains__(i):
ls1.remove(i)
final_ls=ls+ls1
print(final_ls)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
An input of n integers is taken at the run time.
n integers are taken as input in a single line, separated by a space.
We have to create a tuple of this n integers and perform hash(tuple) function on it and give the output.
Here it is:
def your_homework():
return hash(tuple([int(i) for i in input("give me n integers").split()]))
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am using Python with Pandas. How can I multiply a column by 1000 given another column has a certain string?
This should do it.
df['columnname'] = np.where(df['othercolumn'] == 'CertainString',
df['columnname'] * 1000,
df['columnname'])