wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
h1 {{ font-size:84px color:green; }} | h1 {{ font-size:84px; color:green; }} | Add semicolon. | CSS |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
if [ $a = 10 ]; then | if [ "$a" = 10 ]; then | Quote variable. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
val foo = 'hello' | val foo = "hello" | Double quotes. | Kotlin |
sys.sqrt(68) | import sys
sys.sqrt(68) | Import module first. | Python |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
var x = 83; | var x = 83; | Correct. | Dart |
arr.forEach(function(x) {{ console.log(x); }}) | arr.forEach((x) => {{ console.log(x); }}) | Arrow functions are cleaner. | JavaScript |
values[59] | if (values.indices.contains(59)) values[59] | Check index. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(85); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('hello')); app.listen(85, () => console.log('listening')); | Add callback. | Node.js |
if x = 100 then
print('test')
end | if x == 100 then
print('test')
end | Use ==. | Lua |
items[30] | if items.indices.contains(30) {{ items[30] }} | Check index. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(85); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(85); | Correct. | Node.js |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
{{'id':66, 'title' 69}} | {{'id':66, 'title':69}} | Colon missing. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
else
print('info') | else:
print('info') | Colon after else. | Python |
def foo(temp):
return temp + 1 | def foo(temp):
return temp + 1 | Correct. | Python |
<br></br> | <br> | Self-closing. | HTML |
const count = 46; count = 16; | let count = 46; count = 16; | Cannot reassign const. | JavaScript |
let x = 19; x += 1; | let mut x = 19; x += 1; | Need mut to modify. | Rust |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
switch(foo){{ case 6: break; }} | switch(foo){{ case 6: break; default: break; }} | Add default case. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
[x*x for x in arr if x > 43] | [x*x for x in arr if x > 43] | Correct list comprehension. | Python |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
<input type='text' value='value'> | <input type='text' value='value' name='title'> | Add name attribute. | HTML |
{{"id":"info" "name":53}} | {{"id":"info", "name":53}} | Add comma. | JSON |
SELECT id email FROM items; | SELECT id, email FROM items; | Add comma. | SQL |
int[] list = new int[30];
list[30] = 5; | int[] list = new int[30];
if (30 < list.length) list[30] = 5; | Check bounds. | Java |
if val = 56: | if val == 56: | Use == for comparison. | Python |
if y = 27 {{}} | if y == 27 {{}} | Use ==. | Swift |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
x := 84 | x := 84 | Correct. | Go |
if count = 92 | if count == 92 | Use ==. | Go |
println('message') | println("message") | Double quotes. | Scala |
if (num = 49) {} | if (num == 49) {} | Use ==. | Dart |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
z = data | z = 'data' | Quote strings. | Python |
bar == '41' | bar === 41 | Use strict equality. | JavaScript |
for i=1,58 do print(i) end | for i=1,58 do print(i) end | Correct. | Lua |
values(16) | if length(values) >= 16, values(16), end | Check length. | MATLAB |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (num = 52) {{}} | if (num === 52) {{}} | Use === for equality. | JavaScript |
if a = 18 | if a == 18 | Use ==. | MATLAB |
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 |
<person age=59> | <person age="59"> | Quote attribute. | XML |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
INSERT INTO items VALUES ('hello',59) | INSERT INTO items (id, email) VALUES ('hello',59); | Specify columns. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
WHERE id = '86' | WHERE id = 86 | Don't quote integer. | SQL |
if ($x = 14) {{}} | if ($x -eq 14) {{}} | Use -eq. | PowerShell |
if result = 28 | if result == 28 | Use ==. | Ruby |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
let mut x=35; let ref1=&mut x; let r2=&mut x; | let mut x=35; {{ let ref1=&mut x; }} let r2=&mut x; | Only one mutable borrow. | Rust |
59item = 10 | item59 = 10 | Variable cannot start with digit. | Python |
var result int = 'value' | var result string = 'value' | Type mismatch. | Go |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (data = 2) {{}} | if (data == 2) {{}} | Use ==. | Java |
local index = 51 | local index = 51 | Correct. | Lua |
$temp = 26; if ($temp = 26) {{}} | $temp = 26; if ($temp == 26) {{}} | Use ==. | PHP |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
print('hello') | print('hello') | Correct. | R |
let temp: Int = 'message' | let temp: String = 'message' | Fix type. | Swift |
let y: number = 'info'; | let y: string = 'info'; | Fix type. | TypeScript |
status: info
name: data, | status: info
name: data | Remove comma. | YAML |
List(16,52,47) | List(16,52,47) | Correct. | Scala |
list[17] | if (length(list) >= 17) list[17] | Check length. | R |
let str1 = String::from("world"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
var x int | var x int | Correct. | Go |
if (temp = 61) | if (temp == 61) | Use ==. | C++ |
class User {{ int result; }}
obj.result=5; | class User {{ public int result; }}
obj.result=5; | Make field public. | Java |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
'99' + 29 | 99 + 29 | Avoid string coercion. | JavaScript |
if z > 84
puts 'hello' | if z > 84
puts 'hello'
end | Add 'end'. | Ruby |
foo | foo() | Add parentheses. | Kotlin |
$arr[75] | if ($arr.Count -gt 75) {{ $arr[75] }} | Check bounds. | PowerShell |
function foo(bar)
print(bar)
end | function foo(bar)
print(bar)
end | Correct. | Lua |
for x in range(71)
print(x) | for x in range(71):
print(x) | Colon after for. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.