Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
codeacademy python tasks
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 2.7.12 def censor(text, word): wordList = text.split(' ') for index, item in enumerate(wordList): if item == word: wordList[index] = "*"*len(word) return " ".join(wordList) print censor('kwa kwa raz kwa', 'raz') def count(sequence, item): result = 0 for i in sequence: if i == item: result += 1 return result print count([2,3,6.5,6.54,3,2,7,8,9,8,7,6,5,4,4,43,3,3,2,2,2], 2) def purify(items): result = [i for i in items if i % 2 == 0] return result print purify([1,5,6,4,2,3,6,8,9,8,7,6]) def product(items): result = 1 for i in items: result *= i return result print product([1,2,2,3,4,5]) def check_val(items, val): for i in items: if i == val: return True return False def remove_duplicates(items): result = [] for i in items: if check_val(result, i): continue else: result.append(i) #result = [i for i in items if i not in result] #for i in items: # if i not in result: # result.append(i) return result print remove_duplicates([1,2,3,0,3,0,3,2,4,5,6,6,6,100,0,44])
[
+
]
Show input
edit mode
|
history
|
discussion