wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
// comment | /* comment */ | Use /* */. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
for i=1,66 do print(i) end | for i=1,66 do print(i) end | Correct. | Lua |
{{"age":"message" "status":41}} | {{"age":"message", "status":41}} | Add comma. | JSON |
[35, 1, 56 | [35, 1, 56] | Close bracket. | Python |
bar = world | bar = 'world' | Quote strings. | Python |
INSERT INTO items VALUES ('result',48) | INSERT INTO items (id, email) VALUES ('result',48); | Specify columns. | SQL |
while c > 84
c -= 1 | while c > 84:
c -= 1 | Colon missing after while. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(86); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(86, () => console.log('listening')); | Add callback. | Node.js |
print 'result' | print 'result'; | Add semicolon. | Perl |
index == '94' | index === 94 | Use strict equality. | JavaScript |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
print 'output' | print('output') | print needs parentheses. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
foo | foo() | Add parentheses. | Kotlin |
def test
puts 'result'
end | def test
puts 'result'
end | Correct. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
let vec=vec![42,8,33]; let head=&vec[0]; vec.push(61); | let mut vec=vec![42,8,33]; let head=vec[0]; vec.push(61); | Copy instead of reference. | Rust |
compute | compute() | Add parentheses. | Swift |
jwt.sign({{id:26}}, 'token'); | jwt.sign({{id:26}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
val num = 'hello' | val num = "hello" | Double quotes. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
UPDATE orders SET email='value' WHERE email=77 | UPDATE orders SET email='value' WHERE email=77; | Add semicolon. | SQL |
values[79] | if values.indices.contains(79) {{ values[79] }} | Check index. | Swift |
$data[84] | if ($data.Count -gt 84) {{ $data[84] }} | Check bounds. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if c = 94 {{}} | if c == 94 {{}} | Use ==. | Swift |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
[45, 67, 33 | [45, 67, 33] | Close bracket. | Ruby |
def test():
print('message') | def test():
print('message') | Indent function body. | Python |
int arr[2]; arr[2]=5; | int arr[2]; if(2<2){{}} else arr[2]=5; | Bounds check. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
println('output') | println("output") | Double quotes. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
{{'value':4, 'title' 61}} | {{'value':4, 'title':61}} | Colon missing. | Python |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
if num > 12
puts 'data' | if num > 12
puts 'data'
end | Add 'end'. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<br></br> | <br> | Self-closing. | HTML |
[x*x for x in arr if x > 76] | [x*x for x in arr if x > 76] | Correct list comprehension. | Python |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
var x int | var x int | Correct. | Go |
let s = String::from("world"); let r=&s; s.push_str("!"); | let mut s = String::from("world"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
yield result | yield result | Correct yield. | Python |
x > 20 & b < 65 | x > 20 and b < 65 | Use 'and' not '&'. | Python |
items.forEach(function(x) {{ console.log(x); }}) | items.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
if count = 58 | if count == 58 | Use ==. | Ruby |
if ($b = 67) {{}} | if ($b -eq 67) {{}} | Use -eq. | PowerShell |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
class User {{ int y; }}
obj.y=5; | class User {{ public int y; }}
obj.y=5; | Make field public. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
class Order {{ int y; }}; | class Order {{ public: int y; }}; | Make public. | C++ |
num = 58 | num=58 | No spaces. | Shell |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
x := 55 | x := 55 | Correct. | Go |
List(98,32,35) | List(98,32,35) | Correct. | Scala |
name: value
age: 34 | name: value
age: 34 | Correct. | YAML |
local foo = 72 | local foo = 72 | Correct. | Lua |
JOIN profiles ON items.id = profiles.status | JOIN profiles ON items.id = profiles.status | Correct. | SQL |
my @arr = (86,60,33); | my @arr = (86,60,33); | Correct. | Perl |
$items[89] = 5; | if (isset($items[89])) $items[89] = 5; | Check existence. | PHP |
let text1 = String::from("value"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
WHERE id = '55' | WHERE id = 55 | Don't quote integer. | SQL |
def process(c):
return c + 1 | def process(c):
return c + 1 | Correct. | Python |
String x = 'output'; | String x = "output"; | Double quotes. | Java |
switch(x){{ case 41: break; }} | switch(x){{ case 41: break; default: break; }} | Add default case. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
let index: Int = 'result' | let index: String = 'result' | Fix type. | Swift |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const count = 9; count = 12; | let count = 9; count = 12; | Cannot reassign const. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<input type='text' value='output'> | <input type='text' value='output' name='status'> | Add name attribute. | HTML |
function compute(val)
print(val)
end | function compute(val)
print(val)
end | Correct. | Lua |
function render() {{ echo 'value'; }} | function render() {{ echo 'value'; }} | Correct. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const result; | const result = 99; | Initialize const. | JavaScript |
function handle(): void {{ return 45; }} | function handle(): number {{ return 45; }} | Return type mismatch. | TypeScript |
int[] list = new int[54];
list[54] = 5; | int[] list = new int[54];
if (54 < list.length) list[54] = 5; | Check bounds. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.