NEW Feature: Codebytes

Hi Friends :wave:

Good news! The team at Codecademy HQ has recently released a new feature: Codebytes! Codebytes are a new and easy way to write, share, and edit executable code blocks here, in the Codecademy forums. Just add a Codebyte to your forum post, select the coding language, and get coding. You can even copy and edit other learners’ Codebytes — so helping each other is easy!

:sparkles: Notable Features:

  • Embed executable code directly in a Forum post or reply to get feedback, support, or to share your code snippet with the Codecademy community
  • No setup required. Write, share and run code directly in Codecademy Forums, right from your browser in the same look and feel of the Codecademy IDE.

:pushpin: What languages are supported?

We currently support the following languages:

  • Python
  • Ruby
  • JavaScript
  • C++
  • C#
  • Go
  • PHP

Below are some screenshots that illustrate where you can find the feature and how it’s used.

Edits to the code in the editing window will automatically update the code in the preview pane. However, edits to the code in the preview pane will not save to your post until you click the “Save to Post” button.

To remove your Codebyte, simply delete the tags.

Clicking “Run” in the preview pane will run your code and show you your output.

For common FAQs, please visit this help center article. Alternatively, feel free to ask a question or comment below. :smiley:

16 Likes

It’s pretty cool.

print("Spoilers don't seem to be compatible")
1 Like
print('I like it')
4 Likes

This is cool :sunglasses:, it creates room for collaboration, which is what we need​:+1:.

1 Like

Cool feature!
Is there any way to make it bigger, vertically? Feels a little small if more than just a couple lines of code are in there.

2 Likes

will this cause any security problems?

3 Likes
print('Codebytes are cool!')

This is cool, I love it

2 Likes

Really cool!! Is there a way to apply indentation to code block?

<?php echo 'Great news'; ?>
1 Like

Love it! Very cool :heart_eyes:

1 Like

Good question! I’ll find out for you.

Edit: It isn’t currently available and the team does not have any immediate plans to implement this capability but it’s possible they’ll add it in the future.

1 Like

Hi, I was doing an explanation of some code where I had to import numpy, but apparently that is not working? Am I missing something or are imports currently not possible?

# apparently I can't import numpy here? import numpy as np list_rowshape = np.array([1,2,3,4,5,6]) list_columnshape = list.reshape(-1,1) print(list_rowshape) # prints: # array([1,2,3,4,5,6]) print(list_columnshape) # prints: # array([[1], # [2], # [3], # [4], # [5], # [6]])
console.log('Thank you for this awesome feature!');

This is my Scrabble.py file:

letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] letter_to_points = {letter: point for letter, point in zip(letters, points)} lowercase_letter_to_points = {letter.lower(): point for letter, point in zip(letters, points)} letter_to_points.update(lowercase_letter_to_points) letter_to_points[""] = 0 def score_word(word): point_total = 0 for letter in word: point_total += letter_to_points.get(letter, 0) return point_total #brownie_points = score_word("BROWNIE") #print(brownie_points) player_to_words = {"player1": ["BLUE", "TENNIS", "EXIT"], "wordNerd": ["EARTH", "EYES", "MACHINE"], "Lexi Con": ["ERASER", "BELLY", "HUSKY"], "Prof Reader": ["ZAP", "COMA", "PERIOD"]} player_to_points = {} def update_point_totals(): for player, words in player_to_words.items(): player_points = 0 for word in words: player_points += score_word(word) player_to_points[player] = player_points def play_word(player, word): player_to_words[player].append(word) def show_player_to_points(): for player, points in player_to_points.items(): print("{player} has scored {points} points.".format(player = player, points = points)) while True: for player in player_to_words.keys(): word = input("{player} can you please enter a word.".format(player = player)) play_word(player, word) update_point_totals() show_player_to_points()

Why does this give an error message?

I think imports are not possible. This is a shared IDE.