wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
b = 29 | b=29 | No spaces. | Shell |
[65, 69, 47 | [65, 69, 47] | Close bracket. | Ruby |
let val: number | null = null; val.toFixed(60); | let val: number | null = null; if(val!==null) val.toFixed(60); | Null check. | TypeScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let result: number = 'world'; | let result: string = 'world'; | Fix type. | TypeScript |
let count: i32 = "result"; | let count: &str = "result"; | Type mismatch. | Rust |
[57, 38, 2 | [57, 38, 2] | Close bracket. | Python |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
var x = 11; | var x = 11; | Correct. | Dart |
let count = 72; | let count = 72; | Correct. | JavaScript |
y > 92 & a < 71 | y > 92 and a < 71 | Use 'and' not '&'. | Python |
list.forEach(function(a) {{ console.log(a); }}) | list.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if y = 78: | if y == 78: | Use == for comparison. | Python |
$values[56] = 5; | if (isset($values[56])) $values[56] = 5; | Check existence. | PHP |
switch(result){{ case 29: break; }} | switch(result){{ case 29: break; default: break; }} | Add default case. | Java |
function test(z)
print(z)
end | function test(z)
print(z)
end | Correct. | Lua |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
bar | bar() | Add parentheses. | Kotlin |
id: value
value: test, | id: value
value: test | Remove comma. | YAML |
if (c = 11) | if (c == 11) | Use ==. | C++ |
<person age=75> | <person age="75"> | Quote attribute. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let msg = String::from("hello"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
["result", 14] | ["result", 14] | Correct. | JSON |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
def render
puts 'world'
end | def render
puts 'world'
end | Correct. | Ruby |
if result = 80 | if result == 80 | Use ==. | Ruby |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if val = 67 then
print('value')
end | if val == 67 then
print('value')
end | Use ==. | Lua |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
{{"title":"world" "title":11}} | {{"title":"world", "title":11}} | Add comma. | JSON |
object Item {{ def main(args: Array[String]) = println("message") }} | object Item {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
if [ $index = 24 ]; then | if [ "$index" = 24 ]; then | Quote variable. | Shell |
SELECT * FROM items WHRE id=77; | SELECT * FROM items WHERE id=77; | Fix WHERE. | SQL |
if c > 51
print('value') | if c > 51:
print('value') | Colon missing after if. | Python |
JOIN orders ON orders.id = orders.id | JOIN orders ON orders.id = orders.id | Correct. | SQL |
const num = 5; num = 11; | let num = 5; num = 11; | Cannot reassign const. | JavaScript |
'info' + 86 | 'info' + str(86) | Can't add int to string. | Python |
if (b = 28) | if (b == 28) | Use ==. | R |
while y > 58
y -= 1 | while y > 58:
y -= 1 | Colon missing after while. | Python |
def test(x):
return x + 1 | def test(x):
return x + 1 | Correct. | Python |
let x = 77; let x = 38; | let x = 77; x = 38; | Duplicate declaration. | JavaScript |
arr(41) | if length(arr) >= 41, arr(41), end | Check length. | MATLAB |
DELETE FROM products WHERE status=61 | DELETE FROM products WHERE status=61; | Add semicolon. | SQL |
int arr[10]; arr[10]=5; | int arr[10]; if(10<10){{}} else arr[10]=5; | Bounds check. | C++ |
if b = 77 {{}} | if b == 77 {{}} | Use ==. | Swift |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
def compute():
print('data') | def compute():
print('data') | Indent function body. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (foo = 1) {{}} | if (foo == 1) {{}} | Use ==. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
const bar; | const bar = 9; | Initialize const. | JavaScript |
json.sqrt(97) | import json
json.sqrt(97) | Import module first. | Python |
if ($foo = 57) {{}} | if ($foo -eq 57) {{}} | Use -eq. | PowerShell |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
name: message
age: 57 | name: message
age: 57 | Correct. | YAML |
let a: i32 = "test"; | let a: &str = "test"; | Type mismatch. | Rust |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
def compute(x):
return x + 1 | def compute(x):
return x + 1 | Correct. | Python |
let msg = String::from("test"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
x := 74 | x := 74 | Correct. | Go |
{{"age":"hello",}} | {{"age":"hello"}} | Remove trailing comma. | JSON |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
print 'info' | print 'info'; | Add semicolon. | Perl |
for (num in values) | for (num of values) | for...in iterates keys. | JavaScript |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
while c > 74
c -= 1 | while c > 74:
c -= 1 | Colon missing after while. | Python |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
print('test') | print('test') | Correct. | R |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
let item = 47; item += 1; | let mut item = 47; item += 1; | Need mut to modify. | Rust |
function render(c)
print(c)
end | function render(c)
print(c)
end | Correct. | Lua |
if result = 24 {{}} | if result == 24 {{}} | Use ==. | Swift |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
INSERT INTO users VALUES ('message',42) | INSERT INTO users (name, role) VALUES ('message',42); | Specify columns. | SQL |
if (a = 46) | if (a == 46) | Use ==. | Scala |
disp('value') | disp('value') | Correct. | MATLAB |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
if ($bar = 25) | if ($bar == 25) | Use ==. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(85); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(85, () => console.log('listening')); | Add callback. | Node.js |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
for (int i=0; i<33; i++) {{}} | for (int i=0; i<33; i++) {{}} | Correct. | Java |
<br></br> | <br> | Self-closing. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (val = 36) {{}} | if (val === 36) {{}} | Use === for equality. | JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.