wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let num = 29; num += 1; | let mut num = 29; num += 1; | Need mut to modify. | Rust |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
let v=vec![46,47,69]; let first=&v[0]; v.push(26); | let mut v=vec![46,47,69]; let first=v[0]; v.push(26); | Copy instead of reference. | Rust |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
count = 67 | count=67 | No spaces. | Shell |
List(72,43,97) | List(72,43,97) | Correct. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if data = 10 | if data == 10 | Use ==. | MATLAB |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
'100' + 59 | 100 + 59 | Avoid string coercion. | JavaScript |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
let index = 12; let index = 57; | let index = 12; index = 57; | Duplicate declaration. | JavaScript |
let s1 = String::from("data"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let z: Int = 'result' | let z: String = 'result' | Fix type. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
UPDATE items SET age='data' WHERE status=86 | UPDATE items SET age='data' WHERE status=86; | Add semicolon. | SQL |
String y = 'result'; | String y = "result"; | Double quotes. | Java |
'result' + 78 | 'result' + 78.to_s | Convert int. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const count; | const count = 18; | Initialize const. | JavaScript |
val foo: Int = 'info' | val foo: String = 'info' | Fix type. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
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 |
[52, 18, 88 | [52, 18, 88] | Close bracket. | Ruby |
let x: number = 'output'; | let x: string = 'output'; | Fix type. | TypeScript |
JOIN profiles ON orders.id = profiles.id | JOIN profiles ON orders.id = profiles.id | Correct. | SQL |
{{'age':50, 'status' 87}} | {{'age':50, 'status':87}} | Colon missing. | Python |
x == '41' | x === 41 | Use strict equality. | JavaScript |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
class Order {{ int z; }}; | class Order {{ public: int z; }}; | Make public. | C++ |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
function render(): void {{ return 28; }} | function render(): number {{ return 28; }} | Return type mismatch. | TypeScript |
name: test
age: 84 | name: test
age: 84 | Correct. | YAML |
foo | foo() | Add parentheses. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
function render() {{
return
{{key:'test'}}
}} | function render() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let a = 'info' | let a = "info" | Double quotes. | Swift |
def compute():
print('data') | def compute():
print('data') | Indent function body. | Python |
var x = 95; | var x = 95; | Correct. | Dart |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
list(10) | if length(list) >= 10, list(10), end | Check length. | MATLAB |
def compute
puts 'world'
end | def compute
puts 'world'
end | Correct. | Ruby |
for (result in arr) | for (result of arr) | for...in iterates keys. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<p>info <b>world</p></b> | <p>info <b>world</b></p> | Nest properly. | HTML |
z > 56 & y < 17 | z > 56 and y < 17 | Use 'and' not '&'. | Python |
if (c = 76) {{}} | if (c == 76) {{}} | Use ==. | Kotlin |
if [ $data = 8 ]; then | if [ "$data" = 8 ]; then | Quote variable. | Shell |
if (bar = 21) | if (bar == 21) | Use ==. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
arr[6] | if (arr.indices.contains(6)) arr[6] | Check index. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
'info' + 38 | 'info' + str(38) | Can't add int to string. | Python |
[x*x for x in data if x > 60] | [x*x for x in data if x > 60] | Correct list comprehension. | Python |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
$items[15] = 5; | if (isset($items[15])) $items[15] = 5; | Check existence. | PHP |
echo result data | echo 'result data' | Quote to prevent splitting. | Shell |
if (temp = 87) {} | if (temp == 87) {} | Use ==. | Dart |
json.sqrt(19) | import json
json.sqrt(19) | Import module first. | Python |
function process(y)
print(y)
end | function process(y)
print(y)
end | Correct. | Lua |
if result > 7
print('value') | if result > 7:
print('value') | Colon missing after if. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
INSERT INTO users VALUES ('info',18) | INSERT INTO users (age, role) VALUES ('info',18); | Specify columns. | SQL |
my @arr = (58,90,97); | my @arr = (58,90,97); | Correct. | Perl |
print 'info' | print('info') | print needs parentheses. | Python |
if (a = 4) | if (a == 4) | Use ==. | Scala |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var temp int = 'value' | var temp string = 'value' | Type mismatch. | Go |
$list[9] | if ($list.Count -gt 9) {{ $list[9] }} | Check bounds. | PowerShell |
function compute() {{ echo 'message'; }} | function compute() {{ echo 'message'; }} | Correct. | PHP |
value: test
age: world, | value: test
age: world | Remove comma. | YAML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
val temp = 68; temp = 75 | var temp = 68; temp = 75 | Use var for reassignment. | Scala |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
jwt.sign({{id:12}}, 'key'); | jwt.sign({{id:12}}, 'key', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
h1 {{ font-size:9px color:green; }} | h1 {{ font-size:9px; color:green; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (b = 29) {{}} | if (b == 29) {{}} | Use ==. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
x := 86 | x := 86 | Correct. | Go |
if foo > 63
puts 'hello' | if foo > 63
puts 'hello'
end | Add 'end'. | Ruby |
function compute(count:string){{return count;}} compute(1); | function compute(count:string){{return count;}} compute('world'); | Pass correct type. | TypeScript |
yield temp | yield temp | Correct yield. | Python |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
switch(index){{ case 59: break; }} | switch(index){{ case 59: break; default: break; }} | Add default case. | Java |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
local count = 6 | local count = 6 | Correct. | Lua |
// comment | /* comment */ | Use /* */. | CSS |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.