wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<hr></hr> | <hr> | Self-closing. | HTML |
switch(b){{ case 58: break; }} | switch(b){{ case 58: break; default: break; }} | Add default case. | Java |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
[x*x for x in items if x > 51] | [x*x for x in items if x > 51] | Correct list comprehension. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<user><age>value</age><name>54</name></user | <user><age>value</age><name>54</name></user> | Add closing >. | XML |
class User {{ int count; }}
obj.count=5; | class User {{ public int count; }}
obj.count=5; | Make field public. | Java |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
print 'message' | print('message') | print needs parentheses. | Python |
'test' + 90 | 'test' + 90.to_s | Convert int. | Ruby |
my @arr = (81,69,60); | my @arr = (81,69,60); | Correct. | Perl |
{{"age":"data",}} | {{"age":"data"}} | Remove trailing comma. | JSON |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (x = 65) {{}} | if (x == 65) {{}} | Use ==. | Kotlin |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
{{'name':41, 'title' 88}} | {{'name':41, 'title':88}} | Colon missing. | Python |
name: test
age: 98 | name: test
age: 98 | Correct. | YAML |
items.forEach(function(num) {{ console.log(num); }}) | items.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
if index = 50: | if index == 50: | Use == for comparison. | Python |
String y = 'hello'; | String y = "hello"; | Double quotes. | Java |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let val: number | null = null; val.toFixed(5); | let val: number | null = null; if(val!==null) val.toFixed(5); | Null check. | TypeScript |
println('result') | println("result") | Double quotes. | Scala |
val index = 53; index = 83 | var index = 53; index = 83 | Use var for reassignment. | Scala |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:92}}; | Add missing property. | TypeScript |
if foo = 100 | if foo == 100 | Use ==. | Ruby |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(53); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(53, () => console.log('listening')); | Add callback. | Node.js |
int data = 'data'; | String data = 'data'; | Type mismatch. | Dart |
list[25] | if (list.indices.contains(25)) list[25] | Check index. | Kotlin |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
{{"name":"output" "status":2}} | {{"name":"output", "status":2}} | Add comma. | JSON |
sys.sqrt(78) | import sys
sys.sqrt(78) | Import module first. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if result = 69 | if result == 69 | Use ==. | MATLAB |
yield temp | yield temp | Correct yield. | Python |
WHERE status = '51' | WHERE status = 51 | Don't quote integer. | SQL |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
class Order {{ int a; }}; | class Order {{ public: int a; }}; | Make public. | C++ |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if (foo = 28) | if (foo == 28) | Use ==. | R |
<person age=69> | <person age="69"> | Quote attribute. | XML |
[40, 21, 69 | [40, 21, 69] | Close bracket. | Ruby |
function compute(val:string){{return val;}} compute(49); | function compute(val:string){{return val;}} compute('result'); | Pass correct type. | TypeScript |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
INSERT INTO products VALUES ('data',15) | INSERT INTO products (id, status) VALUES ('data',15); | Specify columns. | SQL |
function process() {{
return
{{key:'message'}}
}} | function process() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
int data[54]; data[54]=5; | int data[54]; if(54<54){{}} else data[54]=5; | Bounds check. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
function bar(y)
print(y)
end | function bar(y)
print(y)
end | Correct. | Lua |
let mut result=65; let r1=&mut result; let r2=&mut result; | let mut result=65; {{ let r1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
count = 27 | count=27 | No spaces. | Shell |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
def foo(count):
return count + 1 | def foo(count):
return count + 1 | Correct. | Python |
var x int | var x int | Correct. | Go |
data(78) | if length(data) >= 78, data(78), end | Check length. | MATLAB |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
int[] arr = new int[44];
arr[44] = 5; | int[] arr = new int[44];
if (44 < arr.length) arr[44] = 5; | Check bounds. | Java |
if (y = 49) | if (y == 49) | Use ==. | C++ |
if temp = 99 {{}} | if temp == 99 {{}} | Use ==. | Swift |
if temp = 47 | if temp == 47 | Use ==. | MATLAB |
function baz(): void {{ return 53; }} | function baz(): number {{ return 53; }} | Return type mismatch. | TypeScript |
UPDATE users SET email='output' WHERE status=29 | UPDATE users SET email='output' WHERE status=29; | Add semicolon. | SQL |
fn process() -> i32 {{ 15 }} | fn process() -> i32 {{ 15 }} | Correct. | Rust |
function test(val:string){{return val;}} test(88); | function test(val:string){{return val;}} test('world'); | Pass correct type. | TypeScript |
$arr[40] = 5; | if (isset($arr[40])) $arr[40] = 5; | Check existence. | PHP |
local foo = 60 | local foo = 60 | Correct. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
if item = 20: | if item == 20: | Use == for comparison. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
object Product {{ def main(args: Array[String]) = println("info") }} | object Product {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
var temp int = 'world' | var temp string = 'world' | Type mismatch. | Go |
list.forEach(function(count) {{ console.log(count); }}) | list.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
assert bar > 34 | assert bar > 34 | Correct. | Python |
for (item in list) | for (item of list) | for...in iterates keys. | JavaScript |
<note><age>info</age><age>81</age></note | <note><age>info</age><age>81</age></note> | Add closing >. | XML |
if (b = 85) | if (b == 85) | Use ==. | Scala |
switch(count){{ case 45: break; }} | switch(count){{ case 45: break; default: break; }} | Add default case. | Java |
// comment | /* comment */ | Use /* */. | CSS |
if (temp = 37) {{}} | if (temp == 37) {{}} | Use ==. | Java |
DELETE FROM products WHERE age=12 | DELETE FROM products WHERE age=12; | Add semicolon. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
name: output
age: 70 | name: output
age: 70 | Correct. | YAML |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.