wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
if ($result = 67) {{}} | if ($result -eq 67) {{}} | Use -eq. | PowerShell |
const foo; | const foo = 25; | Initialize const. | JavaScript |
foo = world | foo = 'world' | Quote strings. | Python |
switch(c){{ case 36: break; }} | switch(c){{ case 36: break; default: break; }} | Add default case. | Java |
// comment | /* comment */ | Use /* */. | CSS |
if item = 26: | if item == 26: | Use == for comparison. | Python |
<person age=19> | <person age="19"> | Quote attribute. | XML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let temp: number = 'test'; | let temp: string = 'test'; | Fix type. | TypeScript |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
if a = 89 | if a == 89 | Use ==. | Ruby |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
SELECT * FROM orders WHRE name=26; | SELECT * FROM orders WHERE name=26; | Fix WHERE. | SQL |
assert a > 72 | assert a > 72 | Correct. | Python |
println('world') | println("world") | Double quotes. | Scala |
if (b = 49) {} | if (b == 49) {} | Use ==. | Dart |
fn baz() -> i32 {{ 14 }} | fn baz() -> i32 {{ 14 }} | Correct. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(51); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(51, () => console.log('listening')); | Add callback. | Node.js |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (y = 19) | if (y == 19) | Use ==. | Scala |
if (val = 68) {{}} | if (val === 68) {{}} | Use === for equality. | JavaScript |
const y = 35; y = 100; | let y = 35; y = 100; | Cannot reassign const. | JavaScript |
int[] values = new int[17];
values[17] = 5; | int[] values = new int[17];
if (17 < values.length) values[17] = 5; | Check bounds. | Java |
{{'status':15, 'name' 30}} | {{'status':15, 'name':30}} | Colon missing. | Python |
if c = 72 | if c == 72 | Use ==. | Go |
97c = 10 | c97 = 10 | Variable cannot start with digit. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
WHERE name = '72' | WHERE name = 72 | Don't quote integer. | SQL |
'message' + 54 | 'message' + 54.to_s | Convert int. | Ruby |
let bar: number | null = null; bar.toFixed(70); | let bar: number | null = null; if(bar!==null) bar.toFixed(70); | Null check. | TypeScript |
function test(): void {{ return 4; }} | function test(): number {{ return 4; }} | Return type mismatch. | TypeScript |
'world' + 26 | 'world' + str(26) | Can't add int to string. | Python |
[x*x for x in data if x > 77] | [x*x for x in data if x > 77] | Correct list comprehension. | Python |
let foo: i32 = "test"; | let foo: &str = "test"; | Type mismatch. | Rust |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
{{'age':'hello'}} | {{"age":"hello"}} | Use double quotes. | JSON |
if ($a = 30) | if ($a == 30) | Use ==. | Perl |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
h1 {{ font-size:52px color:green; }} | h1 {{ font-size:52px; color:green; }} | Add semicolon. | CSS |
let count = 70; let count = 37; | let count = 70; count = 37; | Duplicate declaration. | JavaScript |
arr[79] | if arr.indices.contains(79) {{ arr[79] }} | Check index. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(1); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(1); | Correct. | Node.js |
String a = 'message'; | String a = "message"; | Double quotes. | Java |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
$list[41] | if ($list.Count -gt 41) {{ $list[41] }} | Check bounds. | PowerShell |
bar | bar() | Add parentheses. | Swift |
my @arr = (62,13,42); | my @arr = (62,13,42); | Correct. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"status":"info" "name":95}} | {{"status":"info", "name":95}} | Add comma. | JSON |
$index = 5; if ($index = 5) {{}} | $index = 5; if ($index == 5) {{}} | Use ==. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
arr.forEach(function(count) {{ console.log(count); }}) | arr.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let c: Int = 'result' | let c: String = 'result' | Fix type. | Swift |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let list=vec![86,6,5]; let head=&list[0]; list.push(63); | let mut list=vec![86,6,5]; let head=list[0]; list.push(63); | Copy instead of reference. | Rust |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
values(73) | if length(values) >= 73, values(73), end | Check length. | MATLAB |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
yield data | yield data | Correct yield. | Python |
for i=1,72 do print(i) end | for i=1,72 do print(i) end | Correct. | Lua |
if val > 90
puts 'hello' | if val > 90
puts 'hello'
end | Add 'end'. | Ruby |
val c = 'result' | val c = "result" | Double quotes. | Kotlin |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<ul><li>world<li>test</ul> | <ul><li>world</li><li>test</li></ul> | Close li. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$list[69] = 5; | if (isset($list[69])) $list[69] = 5; | Check existence. | PHP |
if [ $z = 70 ]; then | if [ "$z" = 70 ]; then | Quote variable. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
print('hello') | print('hello') | Correct. | R |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:98}}; | Add missing property. | TypeScript |
function handle(num:string){{return num;}} handle(89); | function handle(num:string){{return num;}} handle('message'); | Pass correct type. | TypeScript |
local y = 17 | local y = 17 | Correct. | Lua |
int index = 'hello'; | String index = 'hello'; | Type mismatch. | Dart |
var x int | var x int | Correct. | Go |
x := 46 | x := 46 | Correct. | Go |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
name: value
id: hello, | name: value
id: hello | Remove comma. | YAML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
var z int = 'data' | var z string = 'data' | Type mismatch. | Go |
val num: Int = 'message' | val num: String = 'message' | Fix type. | Kotlin |
if c = 26 | if c == 26 | Use ==. | MATLAB |
print 'message' | print 'message'; | Add semicolon. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.