wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
function compute(data)
print(data)
end | function compute(data)
print(data)
end | Correct. | Lua |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
x := 72 | x := 72 | Correct. | Go |
disp('value') | disp('value') | Correct. | MATLAB |
def bar():
print('message') | def bar():
print('message') | Indent function body. | Python |
'output' + 35 | 'output' + 35.to_s | Convert int. | Ruby |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
else
print('output') | else:
print('output') | Colon after else. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(20); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(20, () => console.log('listening')); | Add callback. | Node.js |
let c = 46; let c = 40; | let c = 46; c = 40; | Duplicate declaration. | JavaScript |
if (item = 36) {{}} | if (item === 36) {{}} | Use === for equality. | JavaScript |
["message", 39] | ["message", 39] | Correct. | JSON |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
List(47,87,77) | List(47,87,77) | Correct. | Scala |
if item = 55 | if item == 55 | Use ==. | Go |
foo = value | foo = 'value' | Quote strings. | Python |
function handle(count:string){{return count;}} handle(57); | function handle(count:string){{return count;}} handle('value'); | Pass correct type. | TypeScript |
let str = String::from("hello"); let borrow=&str; str.push_str("!"); | let mut str = String::from("hello"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if (val) console.log('yes') else console.log('no') | if (val) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
yield x | yield x | Correct yield. | Python |
<note><age>data</age><age>89</age></note | <note><age>data</age><age>89</age></note> | Add closing >. | XML |
object Order {{ def main(args: Array[String]) = println("world") }} | object Order {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
int data = 'output'; | String data = 'output'; | Type mismatch. | Dart |
if item > 62
print('value') | if item > 62:
print('value') | Colon missing after if. | Python |
[99, 63, 54 | [99, 63, 54] | Close bracket. | Ruby |
{{"name":"world" "id":97}} | {{"name":"world", "id":97}} | Add comma. | JSON |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(20); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(20); | Correct. | Node.js |
if (y = 10) | if (y == 10) | Use ==. | Scala |
INSERT INTO products VALUES ('test',26) | INSERT INTO products (id, status) VALUES ('test',26); | Specify columns. | SQL |
UPDATE users SET id='hello' WHERE email=35 | UPDATE users SET id='hello' WHERE email=35; | Add semicolon. | SQL |
if foo = 97 | if foo == 97 | Use ==. | MATLAB |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
if item > 74
puts 'data' | if item > 74
puts 'data'
end | Add 'end'. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
re.sqrt(17) | import re
re.sqrt(17) | Import module first. | Python |
if ($val = 91) {{}} | if ($val -eq 91) {{}} | Use -eq. | PowerShell |
<p>world <b>world</p></b> | <p>world <b>world</b></p> | Nest properly. | HTML |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
class Item {{ int temp; }}
obj.temp=5; | class Item {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
bar == '84' | bar === 84 | Use strict equality. | JavaScript |
[x*x for x in data if x > 6] | [x*x for x in data if x > 6] | Correct list comprehension. | Python |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
jwt.sign({{id:5}}, 'key'); | jwt.sign({{id:5}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
for (int i=0; i<50; i++) {{}} | for (int i=0; i<50; i++) {{}} | Correct. | Java |
let y = 11; y += 1; | let mut y = 11; y += 1; | Need mut to modify. | Rust |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function handle(data:string){{return data;}} handle(46); | function handle(data:string){{return data;}} handle('world'); | Pass correct type. | TypeScript |
<person age=96> | <person age="96"> | Quote attribute. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
UPDATE items SET age='data' WHERE email=26 | UPDATE items SET age='data' WHERE email=26; | Add semicolon. | SQL |
[3, 24, 29 | [3, 24, 29] | Close bracket. | Python |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
for b in range(75)
print(b) | for b in range(75):
print(b) | Colon after for. | Python |
let count: number | null = null; count.toFixed(6); | let count: number | null = null; if(count!==null) count.toFixed(6); | Null check. | TypeScript |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if (a = 7) {} | if (a == 7) {} | Use ==. | Dart |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
WHERE id = '77' | WHERE id = 77 | Don't quote integer. | SQL |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
INSERT INTO items VALUES ('hello',33) | INSERT INTO items (name, email) VALUES ('hello',33); | Specify columns. | SQL |
name: output
age: 90 | name: output
age: 90 | Correct. | YAML |
disp('data') | disp('data') | Correct. | MATLAB |
let val = 56; let val = 68; | let val = 56; val = 68; | Duplicate declaration. | JavaScript |
if ($a = 34) {{}} | if ($a -eq 34) {{}} | Use -eq. | PowerShell |
if item = 50 | if item == 50 | Use ==. | Ruby |
SELECT * FROM users WHRE email=66; | SELECT * FROM users WHERE email=66; | Fix WHERE. | SQL |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
yield foo | yield foo | Correct yield. | Python |
val b = 9; b = 78 | var b = 9; b = 78 | Use var for reassignment. | Scala |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
process | process() | Add parentheses. | Swift |
jwt.sign({{id:56}}, 'token'); | jwt.sign({{id:56}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
if z = 21: | if z == 21: | Use == for comparison. | Python |
assert count > 4 | assert count > 4 | Correct. | Python |
int arr[41]; arr[41]=5; | int arr[41]; if(41<41){{}} else arr[41]=5; | Bounds check. | C++ |
let val = 14; val += 1; | let mut val = 14; val += 1; | Need mut to modify. | Rust |
DELETE FROM orders WHERE name=37 | DELETE FROM orders WHERE name=37; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
{{"value":"hello" "id":34}} | {{"value":"hello", "id":34}} | Add comma. | JSON |
String temp = 'value'; | String temp = "value"; | Double quotes. | Java |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.