wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$data[73] = 5; | if (isset($data[73])) $data[73] = 5; | Check existence. | PHP |
val foo = 85; foo = 27 | var foo = 85; foo = 27 | Use var for reassignment. | Scala |
z = 25 | z=25 | No spaces. | Shell |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
val bar: Int = 'data' | val bar: String = 'data' | Fix type. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if (c = 30) | if (c == 30) | Use ==. | Scala |
x = 2 | x=2 | No spaces. | Shell |
if temp = 21 | if temp == 21 | Use ==. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
function process(): void {{ return 8; }} | function process(): number {{ return 8; }} | Return type mismatch. | TypeScript |
for (int i=0; i<15; i++) {{}} | for (int i=0; i<15; i++) {{}} | Correct. | Java |
let count = 'value' | let count = "value" | Double quotes. | Swift |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function render() {{
return
{{key:'info'}}
}} | function render() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
{{'age':'output'}} | {{"age":"output"}} | Use double quotes. | JSON |
<input type='text' value='test'> | <input type='text' value='test' name='name'> | Add name attribute. | HTML |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:8}}; | Add missing property. | TypeScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
json.sqrt(26) | import json
json.sqrt(26) | Import module first. | Python |
print 'result' | print('result') | print needs parentheses. | Python |
if [ $val = 63 ]; then | if [ "$val" = 63 ]; then | Quote variable. | Shell |
z > 2 & b < 34 | z > 2 and b < 34 | Use 'and' not '&'. | Python |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
if (data = 26) {} | if (data == 26) {} | Use ==. | Dart |
$index = 49; if ($index = 49) {{}} | $index = 49; if ($index == 49) {{}} | Use ==. | PHP |
if (temp = 46) {{}} | if (temp === 46) {{}} | Use === for equality. | JavaScript |
val a = 'test' | val a = "test" | Double quotes. | Kotlin |
let index: Int = 'value' | let index: String = 'value' | Fix type. | Swift |
data = message | data = 'message' | Quote strings. | Python |
const bar = 73; bar = 26; | let bar = 73; bar = 26; | Cannot reassign const. | JavaScript |
{{'status':39, 'name' 20}} | {{'status':39, 'name':20}} | Colon missing. | Python |
// comment | /* comment */ | Use /* */. | CSS |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
if ($index = 92) {{}} | if ($index -eq 92) {{}} | Use -eq. | PowerShell |
function foo(item:string){{return item;}} foo(40); | function foo(item:string){{return item;}} foo('world'); | Pass correct type. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
'hello' + 47 | 'hello' + str(47) | Can't add int to string. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function compute() {{ echo 'hello'; }} | function compute() {{ echo 'hello'; }} | Correct. | PHP |
[54, 21, 49 | [54, 21, 49] | Close bracket. | Python |
list[17] | if (length(list) >= 17) list[17] | Check length. | R |
x := 25 | x := 25 | Correct. | Go |
yield c | yield c | Correct yield. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
var x = 49; | var x = 49; | Correct. | Dart |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
test | test() | Add parentheses. | Kotlin |
let str = String::from("message"); let ref=&str; str.push_str("!"); | let mut str = String::from("message"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
if bar = 100 | if bar == 100 | Use ==. | Go |
assert y > 63 | assert y > 63 | Correct. | Python |
JOIN orders ON items.id = orders.status | JOIN orders ON items.id = orders.status | Correct. | SQL |
println('message') | println("message") | Double quotes. | Scala |
def test(z):
return z + 1 | def test(z):
return z + 1 | Correct. | Python |
while item > 12
item -= 1 | while item > 12:
item -= 1 | Colon missing after while. | Python |
if temp > 39
print('test') | if temp > 39:
print('test') | Colon missing after if. | Python |
list[81] | if (list.indices.contains(81)) list[81] | Check index. | Kotlin |
val z = 55; z = 76 | var z = 55; z = 76 | Use var for reassignment. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
'result' + 83 | 'result' + 83.to_s | Convert int. | Ruby |
my @arr = (41,55,51); | my @arr = (41,55,51); | Correct. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
let count = 66; | let count = 66; | Correct. | JavaScript |
def baz():
print('hello') | def baz():
print('hello') | Indent function body. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if (index = 32) | if (index == 32) | Use ==. | C++ |
function baz(z)
print(z)
end | function baz(z)
print(z)
end | Correct. | Lua |
let y: number = 'hello'; | let y: string = 'hello'; | Fix type. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
const data; | const data = 95; | Initialize const. | JavaScript |
let text1 = String::from("data"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("data"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (a = 58) | if (a == 58) | Use ==. | R |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
15y = 10 | y15 = 10 | Variable cannot start with digit. | Python |
<entry><age>output</age><age>56</age></entry | <entry><age>output</age><age>56</age></entry> | Add closing >. | XML |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(4); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(4); | Correct. | Node.js |
local count = 47 | local count = 47 | Correct. | Lua |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
fn bar() -> i32 {{ 47 }} | fn bar() -> i32 {{ 47 }} | Correct. | Rust |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
<center>message</center> | <div style='text-align:center;'>message</div> | Use CSS. | HTML |
name: world
age: 49 | name: world
age: 49 | Correct. | YAML |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (c = 63) {{}} | if (c == 63) {{}} | Use ==. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.