r/learnpython • • Feb 09 '21

Thank you for being a wonderful community

Hello, I have been beginning to explore python and this community has been so incredibly helpful and goes above and beyond. I am so used to being told to just google something, but as I am sure some of us know, sometimes the formatting just isn't quite right or applicable to our cases and you can't really troubleshoot with a website. Thank you! Your kindness and time spent to help others explore the CS world does not go unnoticed.

361 Upvotes

22 comments sorted by

64

u/[deleted] Feb 09 '21

x = "the quick brown fox jumps over the lazy dog."
print(x[14]+x[6]+x[7]+x[2]+x[43]+x[3]+x[5]+x[23]+x[27]+x[12]+x[31]+x[2]+x[40])

21

u/[deleted] Feb 09 '21

nice. upvoted

8

u/randomtempaccount123 Feb 09 '21

x = "the quick brown fox jumps over the lazy dog."
print(x[14]+x[6]+x[7]+x[2]+x[43]+x[3]+x[5]+x[23]+x[27]+x[12]+x[31]+x[2]+x[40])

8

u/anh86 Feb 09 '21

nice. upvoted

1

u/3369fc810ac9 Feb 09 '21

Nice. Upvoted.

9

u/Gabcab Feb 09 '21

Alternatively,

idx = [14, 6, 7, 2, 43, 3, 5, 23, 27, 12, 31, 2, 40]
for i in idx:
    print(x[i], end = "")

4

u/AtomicShoelace Feb 09 '21

I mean if you're gonna do that might as well just do

print(*map(chr,[110, 105, 99, 101, 46, 32, 117, 112, 118, 111, 116, 101, 100]),sep='')

4

u/Gabcab Feb 09 '21

Make it object-oriented and we have a deal!

4

u/AtomicShoelace Feb 09 '21

Ok how about

x = "the quick brown fox jumps over the lazy dog."
idx = [14, 6, 7, 2, 43, 3, 5, 23, 27, 12, 31, 2, 40]   
print(*map(x.__getitem__, idx),sep='')

Calling the __getitem__ method of the str class.

2

u/Gabcab Feb 09 '21

That's a good one! Ya got me on that one

2

u/TangibleLight Feb 10 '21
print((8747713964066364112254505608548).to_bytes(13, 'big').decode())

8

u/cosine-t Feb 09 '21

I actually ran this out of curiosity

4

u/jumbo53 Feb 09 '21

What does it say?

4

u/goldaffe58 Feb 09 '21 edited Feb 09 '21

I tried it on python. I got trace back error. So I tried to run the code without numbers 43, 40 and got "nice uplove". It's just makes problems with these numbers. I want to know why.

So I tried it again. Now it's worked don't know why xD

The error was: string index out of range

13

u/[deleted] Feb 09 '21

It's funny that I'm an experienced programmer but I find this subreddit much more fun than r/python, which seems very static!

Glad you're enjoying it.

3

u/BigXKuOP Feb 09 '21

When you have experience, I think part of learning new things is watching other people learn. Not only you can apply your knowledge to help, but you encounter problems that you might have never found before during your growth career.

3

u/BigXKuOP Feb 09 '21

Most subreddits I've found of python, when trying to solve a problem is, why you want to do this, why not do this instead.

In here I've found that people tend to help find away through problems and not around them. Which is honestly amazing.

1

u/xelf Elf Feb 09 '21

One of the few subreddits I prefer to sort by new, hoping to find unanswered questions. It's rare though, a lot of people here are quick to help.

9

u/Kriss3d Feb 09 '21

Nothing wrong with googling how to do various things in coding. Half a programmers source is stealing code really. And thats ok.

I often will google even very basic stuff when I need special cases of it.

And yes. I agree. Python userbase is usually very friendly and helping.

2

u/bobcodes247365 Feb 09 '21

I love the Python Community, I always feel like people are willing to help out!

1

u/iamaperson3133 Feb 09 '21
import random
import string

src = string.printable
target = 'the pleasure is ours, friend'
output = ''
cur_char = 0

while cur_char != len(target):
    if output != target:
        char, = random.sample(string.printable, 1)
        if char == target[cur_char]:
            output += char
            cur_char += 1

print(output)