I got this far:
def most_frequent(string):
d = dict()
for key in string:
if key not in d:
...
|
s = 'the brown fox '
...do something here...
s should be 'The Brown Fox'
What's the easiest way to do this?
|
How can I delete the \n and the following letters? Thanks a lot.
wordlist = ['Schreiben\nEs', 'Schreiben', 'Schreiben\nEventuell', 'Schreiben\nHaruki']
for x in wordlist:
...?
|
I want to change every letter in a text to after next following letter. But this program doesnt work. Does anyone know why. Thanks in advance. There is also a minor ... |
I would like to rename files with french letters. I am using glob to browse the files and a function I've found on the Internet to remove the french letters. The ... |
I'm writing a Python script that goes through a directory and gathers certain files, but there are a number of files I want excluded that all start the same.
Example code:
for name ...
|
I need to generate the strings STA and STB.
STA and STB are strings of length 10, and each one can contain only the characters A,T,G or C.
I have to generate all ... |
|
Here's my code:
# B. both_ends
# Given a string s, return a string made of the first 2
# and the last 2 chars of the original string,
# so 'spring' yields 'spng'. However, ...
|
I need to convert a string inputed by a user into morse code. The way our professor wants us to do this is to read from a morseCode.txt file, seperate the ... |
How can I remove special characters and letters from a line read from a text file while preserving the whitespaces? Let's say we have the following contents in a file:
16 ... |
I want to assign a value to each letter in the alphabet, so that a -> 1, b -> 2, c -> 3, ... z -> 26. Something like a function ... |
Say I got a random word like WORD, i want to replace each of the letters of the word with _.
How can I do it? Also, say if there is a ... |
How do i assign a numerical value to each uppercase letter, and then use it later via string and then add up the values.
EG.
A = 1, B = 2, C ...
|
This is an exercise from "How to think like a Computer Scientist". I am learning Python/programming and I'm not sure how to do accomplish this task.
Here is an ... |
s = ['my', 'name']
I want to change the 1st letter of each element in to Upper Case.
s = ['My', 'Name']
|
i have a string like "asdfHRbySFss" and i want to go through one char at a time and see which letters are capitalized, is this possible in python?
|
How would I tell Python to check the below for the letter x and then print "Yes"? The below is what I have so far...
dog = "xdasds"
if "x" is in ...
|
I have a string of letters 'aaabbbcccdddeeefffggg' that i would like to read as 3 letter words. For example, 'aaa','bbb','ccc'...
Is there any code that you know of that can do this ... |
If I have
list='abcdedcba'
and i want:
a=z, b=y, c=x, d=w, e=v
so it would translate to:
translate='zyxwvwxya'
How would I do this?
If I construct a dictionary
>>> d=dict(zip(('a','b','c','d','e'),('z','y','x','w','v')))
and type
>>> example= d[x] for x in list
>>> print ...
|
Trying to create the TV game-show "Lingo" in Python.
In the game, players are trying to guess a five letter word. They start off my randomly guessing a five letter word. ... |
I have a list of strings like this:
list:
('aatt')
('aaga')
('aaac')
('gtag')
#the real list have thousands of strings
the optimal desired result is a tabular separated file like this:
0 ...
|
My homework assignment is to Write a program that reads a string from the user and creates a list of words from the input.Create two lists, one containing the words that ... |
I want to make a function that would uncapitalize capitalized letters.
I was thinking I could do
if x in caps
where caps is a list of all the capital letters, and I had ... |
I want to create a function that would check if first letter of string is in uppercase. This is what I've came up with so far:
def is_lowercase(word):
if ...
|
I need to convert a string of numbers into a string of letters to form words
Example:
if the input to your program is
1920012532082114071825463219200125320615151209190846 it should return
stay hungry. stay foolish.
I have this so ... |
is there a quick way to place a string in the front of another string in python? if so how?
as an example let's say that string = 'pple'. How would I ... |
Is there a way to drop a letter in a string if it repeats?
For example lets say that I have the string aaardvark and I wanted to drop one of the ... |
>>> import string
>>> word = "hello."
>>> word2 = word.replace(string.lowercase, '.')
>>> print word2
hello.
I just want all the lowercase letters to turn into full stops.
What am I doing wrong here?
|
I need help in trying to write a certain part of a program.
The idea is that a person would input a bunch of gibberish and the program will read it till ... |
This is a homework assignment. I just need a nudge.
I'm trying to create a loop in which the letters of a string will be removed when it is beyond a certain ... |
index = [0, 2, 5]
s = "I am like stackoverflow-python"
for i in index:
s = s[i].upper()
print(s)
IndexError: string index out of range
I understand that in ... |
|
|
I did that but still the columns do not come in separated exactly and I am writing a large number of such rows under a loop and all the strings are of different sizes and some are letter and some are numbers. I want it to look like data in excel sheet. Is it possible ? thanks for the response Best ... |
Bazinga, I have seen many post of you, one after another, isn't possible to make one threat with all your question? Have you been reading any Python books? Is the one you are reading not making too clear for you? Change the book then Edit; I've see Kebap told you once already. Is there anyway you could read the threats you ... |
Lets say i have a dictionary = {apples: ('tasty', 3), oranges: ('yummy', 5)} ...how would i get the first letter of the string 'tasty' and of string 'yummy' ? i tries using a for loop and then dictionary.split() and using index [0] for each word but it keeps giving me an error ..could i get some tips/hints as to how i ... |
|
|
|
so I'm trying to make a hangman game and am having trouble removing chosen letters: alphabet = 'abcdefghijklmnopqrstuvwxyz' I want to create a function that will remove a letter once the user has guessed it. def remove_letter(alphabet, guess): """remove letter""" alphabet = alphabet.replace(guess, ' ') return alphabet why will this not remove the letter. how can i remove the letter? thanks ... |
|
Hey Folks, I got a problem... I have written a script that search a word (i.e.. a string) in a file. This works fine except that I would like the string not being capital letter and non-capital letter sensitive. Let's say I am looking for the word "computer" and I would like my script to find "computer" "COMPUTER", "Computer", "CoMPuter" etc... ... |
# Keep your 'input()' if you're on python 3.x str = raw_input("Enter your name: ") count = 0 for char in str: if char == 'd' or char == 'D' count += 1 print "%d d's in %s" % (count, str) |
capitalising every letter in a string using traversal loop by sfilinkdirectory Wed Mar 31, 2010 12:57 am Hi everybody, I have a small issue. I made a new definition called emphasise(sentence) which would emphasise every letter in a given word and add an exclamation mark on the end of it, eg: def emphasise(sentence): """ >>> emphasise("come here please") 'COME HERE ... |
colour = raw_input ("Please enter a colour: ") colour = str.lower(colour) if (colour == "white") or (colour == "black"): print "The colour was black or white" elif (colour[0] >= "l"): print "The colour starts with a letter that comes after \"l\" in the alphabet" else: print "The colour starts ... |
def doubles(a): for n in a: for m in a: if n == m: a = a.replace(n + m, n + ... |
class Mstr(list): """a mutable string class via inherited list and join""" def __str__(self): return ''.join(self) s = "hello" # assign to mutable string this way ms = Mstr(s) print( ms ) # hello ms[0] = 'J' print( ms ) ... |
|
def isOTHER(self): for word in msgstrlist: if word[0].upper() not 'C' or 'R' or 'I' print "Other message has been found" else: print "No other messages were found" |
from sys import argv stringinput = str(argv[1]) lower = stringinput.lower() stringsletters = list(lower) alphabet = list('abcdefghijklmnopqrstuvwxyz') numtimes = { } for letter in alphabet: numtimes[letter] = stringsletters.count(letter) for letter in numtimes: if numtimes[letter] !=0: print letter, numtimes[letter] |
|