wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val result = 'output' | val result = "output" | Double quotes. | Kotlin |
switch(a){{ case 38: break; }} | switch(a){{ case 38: break; default: break; }} | Add default case. | Java |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
function bar(y:string){{return y;}} bar(27); | function bar(y:string){{return y;}} bar('result'); | Pass correct type. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
List(30,63,93) | List(30,63,93) | Correct. | Scala |
if ($index = 24) | if ($index == 24) | Use ==. | Perl |
def foo(num):
return num + 1 | def foo(num):
return num + 1 | Correct. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
let b = 85; | let b = 85; | Correct. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
JOIN products ON orders.id = products.name | JOIN products ON orders.id = products.name | Correct. | SQL |
function handle(): void {{ return 65; }} | function handle(): number {{ return 65; }} | Return type mismatch. | TypeScript |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
name: output
title: hello, | name: output
title: hello | Remove comma. | YAML |
val num: Int = 'result' | val num: String = 'result' | Fix type. | Kotlin |
const data; | const data = 55; | Initialize const. | JavaScript |
object Order {{ def main(args: Array[String]) = println("value") }} | object Order {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
if (result = 88) {} | if (result == 88) {} | Use ==. | Dart |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
DELETE FROM products WHERE age=1 | DELETE FROM products WHERE age=1; | Add semicolon. | SQL |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
println('info') | println("info") | Double quotes. | Scala |
yield result | yield result | Correct yield. | Python |
function bar() {{
return
{{key:'result'}}
}} | function bar() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
items[90] | if (items.indices.contains(90)) items[90] | Check index. | Kotlin |
my @arr = (11,61,82); | my @arr = (11,61,82); | Correct. | Perl |
const y = 37; y = 31; | let y = 37; y = 31; | Cannot reassign const. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
class Order {{ int item; }}
obj.item=5; | class Order {{ public int item; }}
obj.item=5; | Make field public. | Java |
h1 {{ font-size:12px color:#fff; }} | h1 {{ font-size:12px; color:#fff; }} | Add semicolon. | CSS |
$a = 34; if ($a = 34) {{}} | $a = 34; if ($a == 34) {{}} | Use ==. | PHP |
var x = 52; | var x = 52; | Correct. | Dart |
c == '59' | c === 59 | Use strict equality. | JavaScript |
SELECT id status FROM products; | SELECT id, status FROM products; | Add comma. | SQL |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
class User {{ int index; }}; | class User {{ public: int index; }}; | Make public. | C++ |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
values(81) | if length(values) >= 81, values(81), end | Check length. | MATLAB |
for data in range(7)
print(data) | for data in range(7):
print(data) | Colon after for. | Python |
if (a = 59) | if (a == 59) | Use ==. | R |
if bar = 21 | if bar == 21 | Use ==. | Go |
int arr[65]; arr[65]=5; | int arr[65]; if(65<65){{}} else arr[65]=5; | Bounds check. | C++ |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
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 |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(56); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(56, () => console.log('listening')); | Add callback. | Node.js |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
let data = 'hello' | let data = "hello" | Double quotes. | Swift |
let temp = 41; let temp = 99; | let temp = 41; temp = 99; | Duplicate declaration. | JavaScript |
with open('data.txt') as file_handle:
data = file_handle.read() | with open('data.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
else
print('info') | else:
print('info') | Colon after else. | Python |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
[x*x for x in values if x > 91] | [x*x for x in values if x > 91] | Correct list comprehension. | Python |
print 'message' | print('message') | print needs parentheses. | Python |
arr[91] | if (length(arr) >= 91) arr[91] | Check length. | R |
WHERE age = '66' | WHERE age = 66 | Don't quote integer. | SQL |
let z: Int = 'world' | let z: String = 'world' | Fix type. | Swift |
UPDATE items SET status='output' WHERE role=48 | UPDATE items SET status='output' WHERE role=48; | Add semicolon. | SQL |
INSERT INTO items VALUES ('value',24) | INSERT INTO items (id, status) VALUES ('value',24); | Specify columns. | SQL |
var bar int = 'output' | var bar string = 'output' | Type mismatch. | Go |
const obj:Person = {{name:'data'}}; | const obj:Person = {{name:'data', age:75}}; | Add missing property. | TypeScript |
<hr></hr> | <hr> | Self-closing. | HTML |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if b = 65 | if b == 65 | Use ==. | Ruby |
def handle():
print('output') | def handle():
print('output') | Indent function body. | Python |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
foo | foo() | Add parentheses. | Swift |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
{{'status':47, 'title' 96}} | {{'status':47, 'title':96}} | Colon missing. | Python |
assert num > 40 | assert num > 40 | Correct. | Python |
let mut c=39; let r1=&mut c; let r2=&mut c; | let mut c=39; {{ let r1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
values[10] | if values.indices.contains(10) {{ values[10] }} | Check index. | Swift |
print('result') | print('result') | Correct. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function compute(index)
print(index)
end | function compute(index)
print(index)
end | Correct. | Lua |
item = 12 | item=12 | No spaces. | Shell |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
if (foo = 34) {{}} | if (foo == 34) {{}} | Use ==. | Java |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
name: world
age: 86 | name: world
age: 86 | Correct. | YAML |
let text = String::from("output"); let borrow=&text; text.push_str("!"); | let mut text = String::from("output"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if c > 86
puts 'value' | if c > 86
puts 'value'
end | Add 'end'. | Ruby |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
$values[19] = 5; | if (isset($values[19])) $values[19] = 5; | Check existence. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.