kristofer / Some python
0 likes
0 forks
2 files
Last active
| 1 | def countwords(lst): |
| 2 | word_count = {} |
| 3 | |
| 4 | for word in lst: |
| 5 | if word in word_count: |
| 6 | word_count[word] += 1 |
| 7 | else: |
| 8 | word_count[word] = 1 |
| 9 | return word_count |
| 10 |
kristofer / Working with Strings
0 likes
0 forks
1 files
Last active
Working with Strings
In both python and Java, samples of working with common string operations: split, capitalization, concatenation, replacing characters, working with sentences.
Key differences:
- Python: Has built-in title(), capitalize() methods; f-strings for formatting
- Java: More verbose; often requires manual implementation or StringBuilder
- Python: Strings are immutable but syntax is cleaner
kristofer / String Splitting
0 likes
0 forks
1 files
Last active
split a string in both Python and Java
Splitting a String
into a list or array of strings.
Key differences:
- Python returns a list directly
- Java returns an array (String[]), which you can convert to List if needed
- Python uses split() with no argument to split by any whitespace
- Java requires explicit delimiter - use split("\s+") for any whitespace
kristofer / Random Integers (Java & Python)
0 likes
0 forks
1 files
Last active
easy way to generate a random int from to max
If you need to generate a random integer, a number from say, 1 to 6, you can write a couple routines:
Java
import java.util.Random;
int min = 1;
int max = 6;
kristofer / Spark/Docker Troubleshooting Guide
0 likes
0 forks
1 files
Last active
Spark-Docker-SQL - Troubleshooting Guide
🚨 Quick Emergency Fixes
🔥 "Everything is Broken" - Nuclear Option
# Stop everything and restart fresh
docker-compose down -v --remove-orphans
docker system prune -f
docker volume prune -f
Newer
Older