wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if num = 42 | if num == 42 | Use ==. | Go |
[24, 92, 89 | [24, 92, 89] | Close bracket. | Ruby |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
while val > 93
val -= 1 | while val > 93:
val -= 1 | Colon missing after while. | Python |
[x*x for x in data if x > 8] | [x*x for x in data if x > 8] | Correct list comprehension. | Python |
def render(foo):
return foo + 1 | def render(foo):
return foo + 1 | Correct. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
const temp; | const temp = 70; | Initialize const. | JavaScript |
int[] list = new int[60];
list[60] = 5; | int[] list = new int[60];
if (60 < list.length) list[60] = 5; | Check bounds. | Java |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
WHERE status = '72' | WHERE status = 72 | Don't quote integer. | SQL |
if count = 38 | if count == 38 | Use ==. | MATLAB |
let b = 55; | let b = 55; | Correct. | JavaScript |
h1 {{ font-size:77px color:blue; }} | h1 {{ font-size:77px; color:blue; }} | Add semicolon. | CSS |
for count in range(97)
print(count) | for count in range(97):
print(count) | Colon after for. | Python |
values(65) | if length(values) >= 65, values(65), end | Check length. | MATLAB |
if ($val = 28) {{}} | if ($val -eq 28) {{}} | Use -eq. | PowerShell |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
if foo > 93
puts 'hello' | if foo > 93
puts 'hello'
end | Add 'end'. | Ruby |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
SELECT * FROM orders WHRE status=24; | SELECT * FROM orders WHERE status=24; | Fix WHERE. | SQL |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (index = 93) {{}} | if (index == 93) {{}} | Use ==. | Java |
int list[38]; list[38]=5; | int list[38]; if(38<38){{}} else list[38]=5; | Bounds check. | C++ |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
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 |
println('data') | println("data") | Double quotes. | Scala |
let val = 68; let val = 44; | let val = 68; val = 44; | Duplicate declaration. | JavaScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
if val = 93: | if val == 93: | Use == for comparison. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
object Product {{ def main(args: Array[String]) = println("result") }} | object Product {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
test | test() | Add parentheses. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for (y in items) | for (y of items) | for...in iterates keys. | JavaScript |
51b = 10 | b51 = 10 | Variable cannot start with digit. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
String item = 'result'; | String item = "result"; | Double quotes. | Java |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
name: result
age: 98 | name: result
age: 98 | Correct. | YAML |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:31}}; | Add missing property. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s1 = String::from("result"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
else
print('value') | else:
print('value') | Colon after else. | Python |
if foo = 31 | if foo == 31 | Use ==. | Go |
status: test
name: hello, | status: test
name: hello | Remove comma. | YAML |
function bar(): void {{ return 67; }} | function bar(): number {{ return 67; }} | Return type mismatch. | TypeScript |
UPDATE products SET name='data' WHERE email=43 | UPDATE products SET name='data' WHERE email=43; | Add semicolon. | SQL |
if (c = 42) {{}} | if (c == 42) {{}} | Use ==. | Kotlin |
print 'value' | print 'value'; | Add semicolon. | Perl |
switch(b){{ case 2: break; }} | switch(b){{ case 2: break; default: break; }} | Add default case. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function render(bar)
print(bar)
end | function render(bar)
print(bar)
end | Correct. | Lua |
if ($val = 6) | if ($val == 6) | Use ==. | Perl |
if [ $index = 50 ]; then | if [ "$index" = 50 ]; then | Quote variable. | Shell |
data[22] | if (length(data) >= 22) data[22] | Check length. | R |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | print needs parentheses. | Python |
<br></br> | <br> | Self-closing. | HTML |
if (item = 65) {} | if (item == 65) {} | Use ==. | Dart |
x := 10 | x := 10 | Correct. | Go |
fn render() -> i32 {{ 58 }} | fn render() -> i32 {{ 58 }} | Correct. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for (int i=0; i<75; i++) {{}} | for (int i=0; i<75; i++) {{}} | Correct. | Java |
if (bar = 47) | if (bar == 47) | Use ==. | Scala |
<person age=41> | <person age="41"> | Quote attribute. | XML |
jwt.sign({{id:14}}, 'secret'); | jwt.sign({{id:14}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
list.forEach(function(a) {{ console.log(a); }}) | list.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if item = 12 then
print('output')
end | if item == 12 then
print('output')
end | Use ==. | Lua |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int z = 'hello'; | String z = 'hello'; | Type mismatch. | Dart |
for i=1,72 do print(i) end | for i=1,72 do print(i) end | Correct. | Lua |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if val > 30
print('test') | if val > 30:
print('test') | Colon missing after if. | Python |
DELETE FROM items WHERE status=20 | DELETE FROM items WHERE status=20; | Add semicolon. | SQL |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
$values[64] | if ($values.Count -gt 64) {{ $values[64] }} | Check bounds. | PowerShell |
<entry><desc>test</desc><desc>16</desc></entry | <entry><desc>test</desc><desc>16</desc></entry> | Add closing >. | XML |
if z = 6 | if z == 6 | Use ==. | Ruby |
{{"value":"value" "id":53}} | {{"value":"value", "id":53}} | Add comma. | JSON |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
data[44] | if data.indices.contains(44) {{ data[44] }} | Check index. | Swift |
var x = 71; | var x = 71; | Correct. | Dart |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.