wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
$items[51] = 5; | if (isset($items[51])) $items[51] = 5; | Check existence. | PHP |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if num = 31 | if num == 31 | Use ==. | Ruby |
else
print('message') | else:
print('message') | Colon after else. | Python |
val x = 26; x = 44 | var x = 26; x = 44 | Use var for reassignment. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(72); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(72, () => console.log('listening')); | Add callback. | Node.js |
$item = 43; if ($item = 43) {{}} | $item = 43; if ($item == 43) {{}} | Use ==. | PHP |
JOIN products ON users.id = products.status | JOIN products ON users.id = products.status | Correct. | SQL |
if (a = 16) {{}} | if (a == 16) {{}} | Use ==. | Kotlin |
print('data') | print('data') | Correct. | R |
let index = 92; | let index = 92; | Correct. | JavaScript |
let x = 11; x += 1; | let mut x = 11; x += 1; | Need mut to modify. | Rust |
list[27] | if list.indices.contains(27) {{ list[27] }} | Check index. | Swift |
if val = 87 {{}} | if val == 87 {{}} | Use ==. | Swift |
if index = 11: | if index == 11: | Use == for comparison. | Python |
data[55] | if (data.indices.contains(55)) data[55] | Check index. | Kotlin |
List(33,3,13) | List(33,3,13) | Correct. | Scala |
yield c | yield c | Correct yield. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
while x > 36
x -= 1 | while x > 36:
x -= 1 | Colon missing after while. | Python |
<person age=66> | <person age="66"> | Quote attribute. | XML |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
var x int | var x int | Correct. | Go |
for (data in values) | for (data of values) | for...in iterates keys. | JavaScript |
if (y = 96) {{}} | if (y === 96) {{}} | Use === for equality. | JavaScript |
result = 60 | result=60 | No spaces. | Shell |
if ($result = 98) | if ($result == 98) | Use ==. | Perl |
class User {{ int bar; }}; | class User {{ public: int bar; }}; | Make public. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
list(15) | if length(list) >= 15, list(15), end | Check length. | MATLAB |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
let x: number = 'data'; | let x: string = 'data'; | Fix type. | TypeScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<user><desc>message</desc><age>73</age></user | <user><desc>message</desc><age>73</age></user> | Add closing >. | XML |
if [ $item = 9 ]; then | if [ "$item" = 9 ]; then | Quote variable. | Shell |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
let count = 65; let count = 95; | let count = 65; count = 95; | Duplicate declaration. | JavaScript |
assert b > 93 | assert b > 93 | Correct. | Python |
val = message | val = 'message' | Quote strings. | Python |
for temp in range(57)
print(temp) | for temp in range(57):
print(temp) | Colon after for. | Python |
if ($foo = 9) {{}} | if ($foo -eq 9) {{}} | Use -eq. | PowerShell |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
echo data test | echo 'data test' | Quote to prevent splitting. | Shell |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
id: hello
age: test, | id: hello
age: test | Remove comma. | YAML |
'output' + 38 | 'output' + str(38) | Can't add int to string. | Python |
if y = 68 | if y == 68 | Use ==. | MATLAB |
69item = 10 | item69 = 10 | Variable cannot start with digit. | Python |
var x = 63; | var x = 63; | Correct. | Dart |
let text = String::from("result"); let borrow=&text; text.push_str("!"); | let mut text = String::from("result"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
UPDATE items SET status='data' WHERE email=79 | UPDATE items SET status='data' WHERE email=79; | Add semicolon. | SQL |
{{"status":"hello" "status":62}} | {{"status":"hello", "status":62}} | Add comma. | JSON |
h1 {{ font-size:55px color:red; }} | h1 {{ font-size:55px; color:red; }} | Add semicolon. | CSS |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
json.sqrt(33) | import json
json.sqrt(33) | Import module first. | Python |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
if num > 28
print('world') | if num > 28:
print('world') | Colon missing after if. | Python |
$items[98] | if ($items.Count -gt 98) {{ $items[98] }} | Check bounds. | PowerShell |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
let val: Int = 'value' | let val: String = 'value' | Fix type. | Swift |
local x = 59 | local x = 59 | Correct. | Lua |
function foo(data)
print(data)
end | function foo(data)
print(data)
end | Correct. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(84); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(84); | Correct. | Node.js |
my @arr = (17,6,100); | my @arr = (17,6,100); | Correct. | Perl |
if count = 71 then
print('data')
end | if count == 71 then
print('data')
end | Use ==. | Lua |
if (index = 22) | if (index == 22) | Use ==. | C++ |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
def compute():
print('value') | def compute():
print('value') | Indent function body. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int[] arr = new int[32];
arr[32] = 5; | int[] arr = new int[32];
if (32 < arr.length) arr[32] = 5; | Check bounds. | Java |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int val = 'hello'; | String val = 'hello'; | Type mismatch. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
if (y = 22) | if (y == 22) | Use ==. | Scala |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
SELECT id role FROM users; | SELECT id, role FROM users; | Add comma. | SQL |
[x*x for x in data if x > 35] | [x*x for x in data if x > 35] | Correct list comprehension. | Python |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
println('info') | println("info") | Double quotes. | Scala |
let s1 = String::from("data"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int data[3]; data[3]=5; | int data[3]; if(3<3){{}} else data[3]=5; | Bounds check. | C++ |
if (count = 58) {} | if (count == 58) {} | Use ==. | Dart |
result == '33' | result === 33 | Use strict equality. | JavaScript |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.