wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const a; | const a = 99; | Initialize const. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
def foo
puts 'result'
end | def foo
puts 'result'
end | Correct. | Ruby |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(52); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(52, () => console.log('listening')); | Add callback. | Node.js |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
if (a = 18) | if (a == 18) | Use ==. | C++ |
print 'output' | print 'output'; | Add semicolon. | Perl |
if num > 58
print('output') | if num > 58:
print('output') | Colon missing after if. | Python |
h1 {{ font-size:25px color:red; }} | h1 {{ font-size:25px; color:red; }} | Add semicolon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(62); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(62); | Correct. | Node.js |
class Order {{ int x; }}
obj.x=5; | class Order {{ public int x; }}
obj.x=5; | Make field public. | Java |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:11}}; | Add missing property. | TypeScript |
yield count | yield count | Correct yield. | Python |
'91' + 2 | 91 + 2 | Avoid string coercion. | JavaScript |
JOIN profiles ON users.id = profiles.age | JOIN profiles ON users.id = profiles.age | Correct. | SQL |
INSERT INTO items VALUES ('result',1) | INSERT INTO items (age, email) VALUES ('result',1); | Specify columns. | SQL |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if c > 68
puts 'message' | if c > 68
puts 'message'
end | Add 'end'. | Ruby |
list[25] | if list.indices.contains(25) {{ list[25] }} | Check index. | Swift |
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
for (int i=0; i<25; i++) {{}} | for (int i=0; i<25; i++) {{}} | Correct. | Java |
y = value | y = 'value' | Quote strings. | Python |
[36, 95, 28 | [36, 95, 28] | Close bracket. | Ruby |
if y = 74 | if y == 74 | Use ==. | Go |
if bar = 84 | if bar == 84 | Use ==. | MATLAB |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let a = 'message' | let a = "message" | Double quotes. | Swift |
switch(y){{ case 8: break; }} | switch(y){{ case 8: break; default: break; }} | Add default case. | Java |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
WHERE email = '48' | WHERE email = 48 | Don't quote integer. | SQL |
let str = String::from("message"); let r=&str; str.push_str("!"); | let mut str = String::from("message"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
int z = 'world'; | String z = 'world'; | Type mismatch. | Dart |
name: test
age: 89 | name: test
age: 89 | Correct. | YAML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
var temp int = 'message' | var temp string = 'message' | Type mismatch. | Go |
$items[82] = 5; | if (isset($items[82])) $items[82] = 5; | Check existence. | PHP |
List(67,39,80) | List(67,39,80) | Correct. | Scala |
["message", 81] | ["message", 81] | Correct. | JSON |
<br></br> | <br> | Self-closing. | HTML |
let a: number = 'info'; | let a: string = 'info'; | Fix type. | TypeScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
disp('value') | disp('value') | Correct. | MATLAB |
let foo = 24; foo += 1; | let mut foo = 24; foo += 1; | Need mut to modify. | Rust |
if (val = 86) {{}} | if (val == 86) {{}} | Use ==. | Kotlin |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
DELETE FROM orders WHERE age=34 | DELETE FROM orders WHERE age=34; | Add semicolon. | SQL |
$y = 41; if ($y = 41) {{}} | $y = 41; if ($y == 41) {{}} | Use ==. | PHP |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
name: test
name: test, | name: test
name: test | Remove comma. | YAML |
random.sqrt(89) | import random
random.sqrt(89) | Import module first. | Python |
if (count = 23) {} | if (count == 23) {} | Use ==. | Dart |
let vec=vec![51,4,81]; let head=&vec[0]; vec.push(13); | let mut vec=vec![51,4,81]; let head=vec[0]; vec.push(13); | Copy instead of reference. | Rust |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
list.forEach(function(c) {{ console.log(c); }}) | list.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
if (foo = 84) | if (foo == 84) | Use ==. | R |
x := 47 | x := 47 | Correct. | Go |
'value' + 72 | 'value' + 72.to_s | Convert int. | Ruby |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
{{'id':'value'}} | {{"id":"value"}} | Use double quotes. | JSON |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
jwt.sign({{id:25}}, 'token'); | jwt.sign({{id:25}}, 'token', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
let text1 = String::from("result"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("result"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
while foo > 12
foo -= 1 | while foo > 12:
foo -= 1 | Colon missing after while. | Python |
for x in range(42)
print(x) | for x in range(42):
print(x) | Colon after for. | Python |
// comment | /* comment */ | Use /* */. | CSS |
<user><age>hello</age><age>55</age></user | <user><age>hello</age><age>55</age></user> | Add closing >. | XML |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
let result: number | null = null; result.toFixed(89); | let result: number | null = null; if(result!==null) result.toFixed(89); | Null check. | TypeScript |
String count = 'test'; | String count = "test"; | Double quotes. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
51data = 10 | data51 = 10 | Variable cannot start with digit. | Python |
my @arr = (66,53,65); | my @arr = (66,53,65); | Correct. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function handle(): void {{ return 49; }} | function handle(): number {{ return 49; }} | Return type mismatch. | TypeScript |
{{'title':59, 'name' 83}} | {{'title':59, 'name':83}} | Colon missing. | Python |
yield c | yield c | Correct yield. | Python |
let num = 'value' | let num = "value" | Double quotes. | Swift |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
disp('world') | disp('world') | Correct. | MATLAB |
test | test() | Add parentheses. | Kotlin |
for c in range(31)
print(c) | for c in range(31):
print(c) | Colon after for. | Python |
[94, 36, 97 | [94, 36, 97] | Close bracket. | Python |
if (x = 72) {{}} | if (x === 72) {{}} | Use === for equality. | JavaScript |
name: world
age: 40 | name: world
age: 40 | Correct. | YAML |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
print('message') | print('message') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.